String

S

shapper

Hello,

I have the following code line:

myString = myString.Replace("$Name$", Left(myText, InStr(myText, " ") -
1))

I am getting all the text before the first Space in myText and then
replace it in "$Name$"

The problem is that sometimes myText has no space so in that case I
want to get the full text.

Every time this happens I get the error:
Argument 'Length' must be greater or equal to zero.

Could you tell me how to solve this?

Thanks,
Miguel
 
S

Saber

If InStr(myText, " ") > -1 Then

myString = myString.Replace("$Name$", Left(myText, InStr(myText, " ") - 1))

Else : myString = myText

End If
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top