Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax to Concat string with an integer 1

Status
Not open for further replies.

tyang01

Technical User
Feb 1, 2007
46
US
I'm looking for a way to concatenate an integer to the end of a string. I've tried various ways and can't seem to find out. If anyone has an idea how to do it in VBA please let me know. Thanks.
 
I've tried various ways
Which ways ?
FYI, the concatenation operator is &

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This is what i've tried so far. What I'm trying to do is concat a incrementing suffix to the string.

dim x as integer
dim str as string

x=1

for x < 10
("str") & x
next x

also I tried

for x < 10
("str") + x
next x

 
You wanted this ?
Code:
Dim x As Integer
Dim str As String
For x = 1 To 10
  str = "str" & x
  MsgBox str
Next x

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top