473,811 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array of objects changing unusually

hi,
i have an array of 30 adgroup objects, called arrAdGroup. i am using a loop
to traverse through the array to set the adgroup.id property to a value
(which is different every time).
the code sets the value of all the objects in the array to the value of the
last object.
the code is below:

For i = 0 To counter - 1

With oKeyword
..adGroupId = adgroupID(i)
..criterionType =
criterion.com.g oogle.adwords.C riterionType.Ke yword
'.criterionType Specified = True
If BidChange(i) Then
..maxCpc = Bid(i)
..maxCpcSpecifi ed = True
End If
Select Case keywordType(i)
Case 1
..type = criterion.com.g oogle.adwords.K eywordType.Broa d
Case 2
..type = criterion.com.g oogle.adwords.K eywordType.Exac t
Case 3
..type =
criterion.com.g oogle.adwords.K eywordType.Phra se
End Select
If DURLChange(i) Then
..destinationUr l = destinationURL( i)
End If
If paused(i) Then
..paused = True
..pausedSpecifi ed = True
End If
..id = keywordID(i)

End With

' here is where the code is breaking.
If keywordID(i) 0 Then
arrKeyword(i) = oKeyword
End If
' every time this code executes, the previous object that was set in the
earlier 'loop is overwritten and a new instance of the object appears in the
(i) instance of 'the array.
Next

please help.
Aug 24 '07 #1
1 1181
You only have one instance of oKeyword. Each time through the loop
you set various properties of oKeyword, and then at the end you set
arrKeyword(i) = oKeyword.

Each arrKeyword() entry has a reference to the same oKeyword object.
You need to allocate a new oKeyword object each time through the loop.

Also, since you do nothing useful in the For loop if keywordID(i) <= 0
it would be more efficient to put this right after the For:

If keywordID(i) <= 0 Then
Continue For
End If

On Fri, 24 Aug 2007 09:42:03 -0700, R C <RC@discussions .microsoft.com>
wrote:
>hi,
i have an array of 30 adgroup objects, called arrAdGroup. i am using a loop
to traverse through the array to set the adgroup.id property to a value
(which is different every time).
the code sets the value of all the objects in the array to the value of the
last object.
the code is below:

For i = 0 To counter - 1

With oKeyword
.adGroupId = adgroupID(i)
.criterionTy pe =
criterion.com. google.adwords. CriterionType.K eyword
'.criterionTyp eSpecified = True
If BidChange(i) Then
.maxCpc = Bid(i)
.maxCpcSpecifi ed = True
End If
Select Case keywordType(i)
Case 1
.type = criterion.com.g oogle.adwords.K eywordType.Broa d
Case 2
.type = criterion.com.g oogle.adwords.K eywordType.Exac t
Case 3
.type =
criterion.com. google.adwords. KeywordType.Phr ase
End Select
If DURLChange(i) Then
.destinationUr l = destinationURL( i)
End If
If paused(i) Then
.paused = True
.pausedSpecifi ed = True
End If
.id = keywordID(i)

End With

' here is where the code is breaking.
If keywordID(i) 0 Then
arrKeyword(i ) = oKeyword
End If
' every time this code executes, the previous object that was set in the
earlier 'loop is overwritten and a new instance of the object appears in the
(i) instance of 'the array.
Next

please help.
Aug 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2056
by: jerrygarciuh | last post by:
Hello, In this sample script I create an array of objects. Print out their data with print_r().Update their data with a sub called v_set(). Print out data showing the chnages using print_r(). I push the altered objects into a new array and print them out again, still see the updated data. Then I iterate over the original array again with print_r and the objects lose the updates and have their original data. Can anyone explain what I...
3
11481
by: John MacIntyre | last post by:
Hi, Can anybody give me a hint as to how to convert a javascript array into a vbscript array? BTW-it only needs to work in IE5 & 6 Thanks in advance, John MacIntyre VC++ / VB / ASP / Database Developer
8
10235
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when it is assigned a text literal?? HOW can I change the array value to upper case then? What other method exists for arrays? Ex: var GridArrayName1 = new Array(); GridArrayName1 = new Array ('test-value'); GridArrayName1 = GridArrayName1...
32
6529
by: Joe Rattz | last post by:
Hmmm, I wrote the following code. I want an array of bools and I want to intialize them to false. bool bits = new bool; foreach(bool bit in bits) { bit = false; } The compiler complains on the "bit = false;" stating that bit is read-only.
1
5746
by: Craig | last post by:
Hey Everyone - I'm trying to determine the fastest way of moving array information around and could use some help. Here's the setup: Class A stores a DateTime and an amount (a payment). Class B is functionally an array of A objects (representing a cashflow). Class C is functionally an array of B objects (representing an organization of cashflows).
21
3230
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each column. Once the array elements are split, what is the best way to sort them? Thank you. //populate data object with data from xml file. //Data is a comma delimited list of values var jsData = new Array(); jsData = {lib: "#field...
5
28401
by: Paulers | last post by:
Hello all, I have a string array with duplicate elements. I need to create a new string array containing only the unique elements. Is there an easy way to do this? I have tried looping through each element but I am having issues using redim to adjust the new array. Any help or example code would be greatly appreciated. thanks!
23
7427
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
17
7263
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need to show the array data to the end user. Can I do that? How?
0
9724
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9201
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.