Android Question Error description: Missing Keyword: end sub, but there is End If

dais

Member
Licensed User
There is a code:
B4X:
Sub p_OrientationChanged (Azimuth As Float, Pitch As Float, Roll As Float)
    r=Ceil(Roll)
    If r>0 Then
    crossx=crossx+5
    Else
    crossx=crossx-5
    End If
   
    If crossx>740 Then crossx=740
    End If
    crossx=crossx+1
    If crossx<40 Then
    crossx=40
    End If
   
End Sub
So, it shows me error with Error description: Missing Keyword: end sub
How could it be end sub needed here? Am I missing something?
I saw similar post here http://www.b4x.com/android/forum/th...issing-keyword-end-sub-while-not-needed.9849/ , but I can not understand what is wrong with code?
 

RandomCoder

Well-Known Member
Licensed User
It should be "Else If" not just "Else".
 

dais

Member
Licensed User
Thank you. My bad for Else If, but now it shows the same error for End If after If crossx>740Then crossx=740,
what's wrong with it?
 

klaus

Expert
Licensed User
This is wrong:
If crossx > 740 Then crossx = 740
End If


It should be:
If crossx > 740 Then crossx = 740
without the End If

or
If crossx > 740 Then
crossx = 740
End If
 
Top