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,787
Messages
2,569,631
Members
45,338
Latest member
41Pearline46

Latest Threads

Top