SilmaraFlor
asked on
VB6 - Concatenate Variable Names???
Is there a way of concatenating a variable name, "Not the contents". Here is an example of what I want to be able to do:
Dim str1MyVariable1 as String
Dim str1MyVariable2 as String
Dim str2MyVariable1 as String
Dim str2MyVariable2 as String
Dim i as integer
For i = 0 to 4
str(i)MyVariable1 = "Hello"
str(i)MyVariable2 = "Everybody"
Next i
...
Dim str1MyVariable1 as String
Dim str1MyVariable2 as String
Dim str2MyVariable1 as String
Dim str2MyVariable2 as String
Dim i as integer
For i = 0 to 4
str(i)MyVariable1 = "Hello"
str(i)MyVariable2 = "Everybody"
Next i
...
ASKER
Because some of the variables are arrays already! And I want to use the same function to download my 4 different files which have variable data but same layout!
Does this make sense?
Does this make sense?
dim myStr as variant
dim str1(1) as Variant
dim str2(1) as string
myStr = str1
str2(0) = "Hello"
str2(1) = "Everybody"
myStr(0) = str2
str2(0) = "Try"
str2(1) = "This"
myStr(1) = str2
myStr(0)(0) will equal "Hello"
myStr(0)(1) will equal "Everybody"
myStr(1)(0) will equal "This"
myStr(1)(1) will equal "This"
SilmaraFlor, basically, the answer is "no" Once you compile a project, it loses the information about the variables, so concatenation of variable names becomes meaningless.
One way around this, as mentioned above, is to build the variables into multi-dimensional arrays.
Another way is to convert them into collections which are essentially arrays of unrelated items.
One way around this, as mentioned above, is to build the variables into multi-dimensional arrays.
Another way is to convert them into collections which are essentially arrays of unrelated items.
Please maintain this open question:
https://www.experts-exchange.com/questions/20329554/Multiple-step-OLE-DB-operation-generated-errors-Check-each-OLE-DB-status-value-if-available-No-work-was-done.html
Anthony
https://www.experts-exchange.com/questions/20329554/Multiple-step-OLE-DB-operation-generated-errors-Check-each-OLE-DB-status-value-if-available-No-work-was-done.html
Anthony
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all for your responses.
inthedark,
Thank you for your examples, they helped me a lot.
inthedark,
Thank you for your examples, they helped me a lot.
I love user defined types becuase they are fast to use.
I think most of the examples would work but there was a syntaxt error here:
FileSpec.DataFromFile=Spli t(Input(FH ,LOF(FH)), VbCRLF)
Should have been:
FileSpec.DataFromFile=Spli t(Input(LO F(FH), LH),VbCRLF)
Have fund, thanks....
I think most of the examples would work but there was a syntaxt error here:
FileSpec.DataFromFile=Spli
Should have been:
FileSpec.DataFromFile=Spli
Have fund, thanks....
Dim str1(4) as String
Dim str2(4) as String
for i = 0 to UBound(str1)
str1(i) = "Hello"
next
for i = 0 to UBound(str2)
str2(i) = "Everybody"
next