在Visual Basic 6.0程序中,我有一个字符串sTemp,我想确保它不包含引号.我有这条线:
If sTemp.Contains("""") Then
Run Code Online (Sandbox Code Playgroud)
但是当我在sTemp之后键入句点时,我从intellisense中得不到任何东西,当我尝试编译时,我得到以下错误:
Compile error: Invalid qualifier
VB6字符串不是对象,因此字符串变量上没有可以调用的方法.
要测试字符串是否包含引号,您需要使用InStr函数ie
if InStr(sTemp, """") > 0 then ' string contains at least one double quote
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助
更新 这与原始问题无关
威廉,我只是想到了这一点,你可能会觉得它是无用的信息.
使用VB6 有很多方法可以用脚射击自己.
其中不太明显的是
Dim myCollection as new Collection
Run Code Online (Sandbox Code Playgroud)
从来没有什么东西作为新的 CSomething
将变量调暗,然后在第二行,将其分配给新对象.希望这可以帮助.
Dim myCollection as Collection
Set myCollection = New Collection
Run Code Online (Sandbox Code Playgroud)