VBA how to add a string and Integer to make a string

S

Sridhar

Hai friends,

I would be happy if anybody can help me in writting a code for adding
two integer and string to a string

Example:

I have strings

str1 as say image0 as string
num in a loop from 1 - 20, and
str2 as .jpg

my desired result is

str3 should be as str1 + num + str2

for all strings its working when i introduce an integer its showing
error
any of you please help me out.

Friendly
sridhar
 
M

Mike Fogleman

str3 = "image0" & num & ".jpg".
This will add a string + Variable num+ string. I don't see a second integer
except the 0 at the end of the first string. You may need to be more
specific as to how you need the result to look.
Mike
 
S

Sridhar NN

Hai friend,

the the method you gave i tried out its not accepting, its giving
runtime error
 
F

Frank Kabel

Hi
the statement should do. You may post your complete code and state
which line which error occurs :)
 
T

Tom Ogilvy

Dim str1 as String
Dim str2 as String
Dim str3 as String
Dim num as Integer

str1 = "image0"
str2 = ".jpg"
for num = 1 to 20
str3 = str1 & num & str2
msgbox str3
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top