Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid Qualifier error in Visual Basic 6.0

Tags:

string

vb6

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

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
like image 603
William Avatar asked Jun 01 '11 16:06

William


2 Answers

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

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

Hope this helps

UPDATE This has nothing to do with the original question

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

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

will have side effects you could never imagine.

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
like image 193
Binary Worrier Avatar answered Nov 14 '22 05:11

Binary Worrier


Try if instr(sTemp, """") > 0 then

like image 34
xpda Avatar answered Nov 14 '22 06:11

xpda