hello i have been told that there is a different method of writing this, such as using if, then , else, i have tried it and am getting all sort, do i need to use, if else then, or if else, condition to get the same result, i don't want to use case, is there another method, if so can you please tell me or better still write it for me

Public Function NOTCH(test2 As Integer, ByVal offset As Integer) As Boolean

Dim NotchCharacter As Integer
NotchCharacter = offset + 1
Select Case test2
Case 1
    If NotchCharacter = 17 Then
    NOTCH = True 'I=Q
    End If
    
Case 2
    If NotchCharacter = 5 Then
    NOTCH = True 'II=E
    End If
    
Case 3
    If NotchCharacter = 22 Then
    NOTCH = True 'III=V
    End If
End Select
End Function

Recommended Answers

All 6 Replies

you mean this ?

Public Function NOTCH(test2 As Integer, ByVal offset As Integer) As Boolean

Dim NotchCharacter As Integer
NotchCharacter = offset + 1

if (test2 = 1) and (NotchCharacter = 17) then
    NOTCH = True 'I=Q
else if (test2 = 2) and (NotchCharacter = 5) then
     NOTCH = True 'II=E
else if (test2 = 3) and (NotchCharacter = 22) then
    NOTCH = True 'III=V
end if

End Function

yes this is what i mean, thank you very much, unfortunatly i am getting errors, such as compiler error and syntax error, the error seem to be in else if code, are you sure we can use the else if code, please help

is should be ElseIf - as one word

hello i have tried to use the ifelse statement, it will work for the first one and the second one, but does not work on the third ifelse, please help

hello i have tried to use the ifelse statement, it will work for the first one and the second one, but does not work on the third ifelse, please help

Not "ifelse", it's "elseif"

This should work:

If (test2=1 AND NC=17) OR (test2=2 AND NC=5) OR (test2=3 AND NC=22) Then
NOTCH = TRUE
End If

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.