467,147 Members | 1,281 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,147 developers. It's quick & easy.

Truncate a String in VBScript

Okay this is a very simple question and I'm embarressed that I don't know it. I know it in C++ and such but for some reason I can't remember the syntax for VBScript. I want to truncate a string based on a character. For example...

http://www.frogs.com?place=egypt

What I want is to remove the ? and everything after it.

Replace doesn't work because I need it to do it regardless of what character it is.
Aug 23 '06 #1
  • viewed: 30215
Share:
2 Replies
Nevermind I found it on another site just now. In case anyone else needs to know it's Left

MyString = Left(MyString,number)

So based on this the following would work.

MyString = "http://www.frogs.com?place=egypt"
number = Instr(MyString,"?") - 1

MyString = Left(Mystring,number)

MyString now equals http://www.frogs.com

Woot
Aug 23 '06 #2
niheel
Expert Mod 2GB
Good job. In the url u forgot the forward slash after frogs.com.

Other than that the code looks good.
Aug 25 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Yannick Turgeon | last post: by
2 posts views Thread by jlmjrdev | last post: by
10 posts views Thread by Mavenos | last post: by
1 post views Thread by adam bob | last post: by
2 posts views Thread by cmdolcet69 | last post: by
5 posts views Thread by Timothy Madden | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.