Question:
Visual Basic 6.0 Run-Time Error with InStr?
Spock
2008-06-05 08:35:46 UTC
The following line of code is giving me "Run-Time Error '5': Invalid procedure call or argument."

foundString = InStr(start, events(i), CODE_TAG_LEFT, vbBinaryCompare)

foundString is an integer, start is an integer (in this case it is equal to zero), events() is a string array, and CODE_TAG_LEFT is a const string. If anyone could point out what my error is, I would greatly appreciate it.
Four answers:
2008-06-05 08:43:33 UTC
The first character in the string is 1, not 0 - you're pointing before the beginning of the string. (Leave the index out if you're starting at the first character - that's the default.)
?
2016-12-14 19:30:48 UTC
Visual Basic Instr
?
2016-11-15 08:46:32 UTC
A null value from a recordset many times shows that (a) you have misnamed the guidance field "StudCourse", or (b) there's a null value interior the certainly field "StudCourse", which could't be assigned to I.SubItems(2). If (a) is the project, purely correcting the fieldname might desire to restore the code. If (b) is the project, attempt changing: l.SubItems(2) = rs!StudCourse With: l.SubItems(2) = iif(isnull(rs!StudCourse),"",rs!StudCour... that would desire to assign an empty string somewhat interior the case the place StudCourse is null.
?
2016-11-05 08:31:20 UTC
Vb6 Instr


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...