473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I declare a variable that allows data to be added to it without losing its existing value?

I seem to recall reading somewhere that there was a keyword that allowed a
variable to have data added to it without losing its contents.

a = "Hi " and
b = "There"

myvar = a
myvar = b

the value of myvar after this would be "Hi There".

How do you do accomplish this?
Nov 12 '05 #1
6 1208
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:hQ5Xb.301971$xy6.1484743@attbi_s02...
I seem to recall reading somewhere that there was a keyword that allowed a
variable to have data added to it without losing its contents.

a = "Hi " and
b = "There"

myvar = a
myvar = b

the value of myvar after this would be "Hi There".

How do you do accomplish this?


There's no keyword to do that, however, you can use:

myvar = myvar & a
myvar =myvar & b

Nov 12 '05 #2
myvar = a & b

Mike Storr
www.veraccess.com
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:hQ5Xb.301971$xy6.1484743@attbi_s02...
I seem to recall reading somewhere that there was a keyword that allowed a
variable to have data added to it without losing its contents.

a = "Hi " and
b = "There"

myvar = a
myvar = b

the value of myvar after this would be "Hi There".

How do you do accomplish this?

Nov 12 '05 #3
"Randy Harris" <ra***@SpamFree.com> wrote in message
news:Y0********************@newssvr28.news.prodigy .com...
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:hQ5Xb.301971$xy6.1484743@attbi_s02...
I seem to recall reading somewhere that there was a keyword that allowed a variable to have data added to it without losing its contents.

a = "Hi " and
b = "There"

myvar = a
myvar = b

the value of myvar after this would be "Hi There".

How do you do accomplish this?


There's no keyword to do that, however, you can use:

myvar = myvar & a
myvar =myvar & b


Well, to be more specific, I am trying to load the contents of an array into
a variable string.

For x = 1 To iNumRecs3 Step 1
myStr = rstMyRecs![Group] & " " & rstMyRecs![Name] & " "
rstMyRecs.MoveNext
Next x

Msgbox("The missing information is" & myStr)


I cannot figure out how to do this. Right now, the myStr gets overwritten
each time through. How can I add to this variable from a loop?
Nov 12 '05 #4
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:Uf6Xb.170681$U%5.797137@attbi_s03...
"Randy Harris" <ra***@SpamFree.com> wrote in message
news:Y0********************@newssvr28.news.prodigy .com...
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:hQ5Xb.301971$xy6.1484743@attbi_s02...
I seem to recall reading somewhere that there was a keyword that
allowed
a variable to have data added to it without losing its contents.

a = "Hi " and
b = "There"

myvar = a
myvar = b

the value of myvar after this would be "Hi There".

How do you do accomplish this?
There's no keyword to do that, however, you can use:

myvar = myvar & a
myvar =myvar & b


Well, to be more specific, I am trying to load the contents of an array

into a variable string.

For x = 1 To iNumRecs3 Step 1
myStr = rstMyRecs![Group] & " " & rstMyRecs![Name] & " "
rstMyRecs.MoveNext
Next x

Msgbox("The missing information is" & myStr)


I cannot figure out how to do this. Right now, the myStr gets overwritten
each time through. How can I add to this variable from a loop?


For x = 1 To iNumRecs3 Step 1
myStr = myStr & rstMyRecs![Group] & " " & rstMyRecs![Name] & "
"
rstMyRecs.MoveNext
Next x

Nov 12 '05 #5
> >
I cannot figure out how to do this. Right now, the myStr gets overwritten each time through. How can I add to this variable from a loop?
For x = 1 To iNumRecs3 Step 1
myStr = myStr & rstMyRecs![Group] & " " & rstMyRecs![Name] &

" "
rstMyRecs.MoveNext
Next x

I must be getting punchy since I used that exact same way of doing things in
many SQL statements but could not see it as a solution here!
Thanks
Nov 12 '05 #6
Alan,
I create a module to put all my global public variables in.
Each variable is prefaced with the word "Public" (g for global)

i.e. Public gstrMyGlobalConstant As String
Public gstrAnotherGlobalConstant as string

These variables can then be set from anywhere in the program and the
value will remain even after the procedure which set them is complete.

In response to your code as listed in your original note, I think you may
want to try something a bit different such as:

gstrMyGlobalConstant = "Hello"
gstrAnotherGlobalConstant = "Alan"

In order to now place BOTH values into one variable you could use:

myvar = gstrMyGlobalConstant & " " & gstrAnotherglobalConstant
the result would be: "Hello Alan"

OR
myvar = gstrMyGlobalConstant
myvar= myvar & " " & gstrAnotherGlobalConstant
the result would again be: "Hello Alan"

Hope this helps.

Tom
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:hQ5Xb.301971$xy6.1484743@attbi_s02...
I seem to recall reading somewhere that there was a keyword that allowed a
variable to have data added to it without losing its contents.

a = "Hi " and
b = "There"

myvar = a
myvar = b

the value of myvar after this would be "Hi There".

How do you do accomplish this?

Nov 12 '05 #7

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

Similar topics

6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
19
by: Skybuck Flying | last post by:
Hi, I think I might have just invented the variable bit cpu :) It works simply like this: Each "data bit" has a "meta data bit". The meta data bit describes if the bit is the ending bit...
1
by: mark | last post by:
I have a main form, and i have another form i need to call on a button press, then id like the result of the child form to pass data back to the parent - without losing any data previously entered...
20
by: MLH | last post by:
120 MyString = "How many copies of each letter do you need?" 150 MyVariant = InputBox(MyString, "How Many?", "3") If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'" If...
20
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.