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

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

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

This article has been dead for over six months. Start a new discussion instead.