Hi guys, I have a situation where I am trying to use the OR statement. And when I'm running the test, I observed that this statement is ignored (or it's not used in the right way). See the code bellow:
In my case I have the MyCheck = 8, and it is ignoring the first condition and checking it's conditions, but should go to the 3rd condition (Else If MyCheck = 8 Then)
I've tried next ways:
IF MyCheck = 1 or 0 or 9 Then
IF MyCheck = 1 or MyCheck = 0 or MyCheck = 9 Then
Can please anyone help me with right use of OR?!
Code:
'querying a 'SELECT' event within DB
Public Function DBSelect(sqlSelect, itemCode)
Dim MyCheck
If Browser("URL:=" & Environment.Value("baseUrl")).Exist Then
set conn = createobject("adodb.connection")
conn.open "DSN=" & Environment.Value("DBdsn") & "; UserID=" & Environment.Value("DBLoginName") & "; Password=" & Environment.Value("DBLoginPass") & ";"
set rs = createobject("adodb.recordset")
'get the value from DB
rs.open sqlSelect, conn
' running the select to find the field we need to know -> dBitem
dBitem = rs(itemCode)
' checking the format of the string got as result of select DB
MyCheck = varType(rs(itemCode))
If MyCheck <> 8 or 1 or 9 or 0 Then
' formating the value of the string - adding max 2 nr.'s after the dot (e.g.: 123.09)
dBitem = FormatNumber(dBitem, 2)
reporter.ReportEvent micPass, "Data BASE:", "the Data within DB for the field: '" & itemCode & "' is: '" & dBitem & "'"
Else IF MyCheck = 1 or MyCheck = 0 or MyCheck = 9 Then
reporter.ReportEvent micWarning, "Data BASE:", "The Data within DB is: 'Null' or there are no values for requested field; So the value was converted to '0.00'. The warning is to inform you that there is no data."
dBitem = "0.00"
Else If MyCheck = 8 Then
reporter.ReportEvent micPass, "Data BASE:", "the Data within DB for the field: '" & itemCode & "' is: '" & dBitem & "'"
End If
End If
End If
rs.close
Else
reporter.ReportEvent micFail, "ERROR:", "The browser was not found!"
End If
DBSelect = dBitem
End Function
In my case I have the MyCheck = 8, and it is ignoring the first condition and checking it's conditions, but should go to the 3rd condition (Else If MyCheck = 8 Then)
I've tried next ways:
IF MyCheck = 1 or 0 or 9 Then
IF MyCheck = 1 or MyCheck = 0 or MyCheck = 9 Then
Can please anyone help me with right use of OR?!