View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Concatenating strings into a variable

Can't seem to find this anywhere and it should be simple.
I have an array ActiveEmp "John", "Joe", "Bob", etc.
I have variables named "UPD_John", "UPD_Joe", "UPD_Bob", etc.
in looping through the array, I want to test the variable true/false

If "UPD_" & ActiveEmp(i) = True Then

"UPD_" & ActiveEmp(i) does equal "UPD_John", etc. but it's not
recognized as a variable that I can test for true/false

Any help would be appreciated.

Thanks


Wrong approach!
Test the array elements to match contents of a string...

Const sEmps$ = "UPD_John,UPD_Joe,UPD_Bob"
For n = LBound(ActiveEmps) To UBound(ActiveEmps)
'note name change to reflect array contains more than one
If InStr(sEmps, "UPD_" & ActiveEmps(n) 0 Then
'do stuff
End If
Next 'n

-OR-

...to use a Boolean...

Dim bEmpExists
'...
bEmpExists = InStr(sEmps, "UPD_" & ActiveEmps(n) 0
If bEmpExists Then...

...but I don't see any point in this type of double testing.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion