子串的VB6索引 [英] VB6 Index of Substring
问题描述
我正在尝试在 VB6 中匹配电子邮件地址字符串中的域名,但这不是我的日常语言.我基本上想从地址(即admin@foo.com)中提取域名进行比较.我想通过获取@"之后的所有内容来提取它,我认为找到@"的索引然后使用 Left$()
可以满足我的需求.如何获取索引?
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., admin@foo.com) 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?
推荐答案
您可以使用 InStr
函数来做到这一点:
You can use the InStr
function to do this:
示例:
s$ = "admin@foo.com"
d$ = Mid$(s$, InStr(1, s$, "@") + 1)
变量 d$ 将以字符串foo.com"结尾.(不要忘记检查以确保 @ 符号存在,否则您最终会得到整个源字符串.)
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.)
这篇关于子串的VB6索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!