Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 Index of Substring

Tags:

string

vb6

I'm trying to match domain names in email address strings in VB6 and it's not my everyday language. I basically want to extract the domain name from an address (i.e., [email protected]) for comparison. I would like to extract it by getting everything after "@" and I think finding the index of "@" and then using Left$() would satisfy my needs. How can I get the index?

like image 753
Jeff LaFay Avatar asked Feb 08 '11 16:02

Jeff LaFay


1 Answers

You can use the InStr function to do this:

Example:

s$ = "[email protected]"
d$ = Mid$(s$, InStr(1, s$, "@") + 1)

The variable d$ would end up with the string "foo.com". (Don't forget to check to make sure that the @ sign is present, otherwise you would just end up with the whole source string.)

like image 120
BP. Avatar answered Oct 12 '22 20:10

BP.