Visual Basic 6.0 中的无效限定符错误 [英] Invalid Qualifier error in Visual Basic 6.0

查看:39
本文介绍了Visual Basic 6.0 中的无效限定符错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Basic 6.0 程序中,我有一个字符串 sTemp,我想确保它不包含引号.我有线路:

In a Visual Basic 6.0 program, I have a string sTemp that I want to ensure does not contain a quotation mark. I have the line:

If sTemp.Contains("""") Then

但是当我在 sTemp 之后输入句点时,我没有从智能感知中得到任何信息,并且当我尝试编译时出现以下错误:

But when I type the period after sTemp, I don't get anything from intellisense, and when I try to compile I get the following error:

Compile error:
Invalid qualifier

推荐答案

VB6 字符串不是对象,因此没有可以调用字符串变量的方法.

VB6 strings are not objects, so there are no methods on the string variable that you can call.

要测试字符串是否包含引号,您需要使用 InStr 函数,即

To test does the string contain quotes you need to use the InStr function i.e.

if InStr(sTemp, """") > 0 then ' string contains at least one double quote

希望能帮到你

UPDATE 这与原问题无关

威廉,我刚刚想到了这个,它是您可能会觉得有用的无关信息.

William, I just thought of this, it is unrelated information that you may find useful.

有很多方法可以用 VB6 用脚射击自己.
其中不太明显的是

There are many ways to shoot yourself in the foot with VB6.
Among the less obvious is the fact that

Dim myCollection as new Collection

会有您无法想象的副作用.

永远不要把东西变暗为 New CSomething

Never DIM something AS New CSomething

将变量调暗,然后在第二行将其分配给一个新对象.希望这会有所帮助.

Dim your variable, then on a second line, assign it to a new object. Hope this helps.

Dim myCollection as Collection
Set myCollection = New Collection

这篇关于Visual Basic 6.0 中的无效限定符错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆