473,804 Members | 3,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1222
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message
news:hQ5Xb.3019 71$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
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message
news:hQ5Xb.3019 71$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******** ************@ne wssvr28.news.pr odigy.com...
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message
news:hQ5Xb.3019 71$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.MoveN ext
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
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message
news:Uf6Xb.1706 81$U%5.797137@a ttbi_s03...
"Randy Harris" <ra***@SpamFree .com> wrote in message
news:Y0******** ************@ne wssvr28.news.pr odigy.com...
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message
news:hQ5Xb.3019 71$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.MoveN ext
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.MoveN ext
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.MoveN ext
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 gstrMyGlobalCon stant As String
Public gstrAnotherGlob alConstant 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:

gstrMyGlobalCon stant = "Hello"
gstrAnotherGlob alConstant = "Alan"

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

myvar = gstrMyGlobalCon stant & " " & gstrAnotherglob alConstant
the result would be: "Hello Alan"

OR
myvar = gstrMyGlobalCon stant
myvar= myvar & " " & gstrAnotherGlob alConstant
the result would again be: "Hello Alan"

Hope this helps.

Tom
"Colleyvill e Alan" <ae***********@ nospam.comcast. net> wrote in message
news:hQ5Xb.3019 71$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
2394
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 email from (possibly) three seperate forms. the following code is the end of a routine which stashes data from the first form off to session variables and then redirects itself to the proper form / procedure depending upon the state of two...
32
3232
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 lost when they move to a new record. This seems to be the case when there are multiple users. When there is a single user using it, we don't seem to have that problem. It seems that we had this problem when we first converted from an MDB back end...
16
25422
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 the properties: mode1, mode2, and mode3. This seems simple but I can't quite figure it out... Any ideas anyone?
19
2149
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 of a possibly large structure/field.
1
317
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 on the parent - is this possible ? ( my main parent window is starting to get quite cluttered) cheers mark
20
3722
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 MyVariant = 2 Then MsgBox "MyVariant also equals the value 2" 160 If MyVariant = "" Then HowManyCopies = 1 170 If Not IsNumeric(MyVariant) Then HowManyCopies = 1 MsgBox "OK. HowManyCopies has a value of " & CStr(HowManyCopies) 180 For i =...
20
12766
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 AutoExec macro calls a function "InitApplication" which, in turn, calls a function to set the value of a global string variable
0
9704
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
10319
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
10070
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
9132
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
7608
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
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
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
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
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.