Confusing VB08 Error

Shibbyman

Chieftain
Joined
Dec 8, 2006
Messages
45
Location
The Speewa, Australia-land
hello, I'm just starting to use VB08 and I've run into a confusing error. I tried to run some code in the form:

if strName = "Bob" Or "Robert" then
inCounter = intCounter + 1
End if

(i.e. using a check for the contents of the string "strName" as a parameter for the loop)

But it keeps giving me the error "Error Option Strict On disallows implicit conversions from 'String' to 'Boolean'."

As you can see I have Option Strict and Option Explicit On so I'm pretty sure it isn't a problem of not declaring something.

My form load contains the following:

Option Strict On
Option Explicit On
Public Class Form1
Dim intCounter As Integer
Dim strName As String
Dim boolFlag As Boolean


Any help would be much appreciated. Thanks in advance.
 
no problem

you were getting this error message
Code:
"Error Option Strict On disallows implicit conversions from 'String' to 'Boolean'."

because

Code:
if strName = "Bob" Or "Robert" then

implies that "Robert" is a boolean, which it is not
 
As long as you're a good programmer, there is a demand for you. Knowing how to program well is more important than knowing a specific language ( Of course, knowing the right language for the job is a big plus too.) If you know how to do the former, learning a new programming language is fairly easy ( compared to learning your first one)
 
Back
Top Bottom