By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

Instrev Function

P: 2
I'm relatively new to VBScript. I'm in the process of developing a page which pulls information from a database such as name, title, phone number, etc. In the database under the name column, it will have someones name and then beside it there will be (title), for example, John Smith (Administrator). I'm trying to get rid of the (Administrator) from the name so it will just display John Smith. I've been doing some googling and it seems that Instrev can do what I what but I have no idea how to use it. Does anyone have any suggestions?
Sep 13 '07 #1
Share this Question
Share on Google+
2 Replies


kadghar
Expert 100+
P: 1,295
I'm relatively new to VBScript. I'm in the process of developing a page which pulls information from a database such as name, title, phone number, etc. In the database under the name column, it will have someones name and then beside it there will be (title), for example, John Smith (Administrator). I'm trying to get rid of the (Administrator) from the name so it will just display John Smith. I've been doing some googling and it seems that Instrev can do what I what but I have no idea how to use it. Does anyone have any suggestions?
wouldnt you mean InStrRev
is like InStr but it starts from the end of the string.

InStr will tell you the position where one string is into another string. e.g.

Instr("Hello World" , "ello") = 2
InStrRev("Hello World", "Wor") = 3

You can combine it with the Left or Right function and you're done. In this case, i recomend you InStr and Left. I'd search the "(" and i think that'll do, something like:

Expand|Select|Wrap|Line Numbers
  1. dim Str1 as string
  2. dim Str2 as string
  3. Str1= "John Smith (Administrator)"
  4. Str2 = Left ( str1, instr(str1, "(" ) )
this way Str2 = "John Smith "
Note i didnt remove the las space, but you can remove with a Trim function.

HTH
Sep 13 '07 #2

P: 2
Works like a charm.

You rock!

Thanks a million :)
Sep 13 '07 #3

Post your reply

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