Bug? Faulty error message on missing 'Then'

nikolaus

Member
Licensed User
Longtime User
Following wrong code:

If a = b
log (a)​
End If​

underlines End If in red and generates the error message:

Missing Keyword: end sub

(B4A 3.80)
 

nikolaus

Member
Licensed User
Longtime User
Yes you are right as I wrote before. The error message is wrong, it states 'Missing Keyword: End Sub'. It should be something like 'Missing Keyword: Then'
 

yazak

Member
Licensed User
Longtime User
A error I have noticed is this

If a=b Then a=1 : b=2

Then above would work like this

If a=b Then a=1
b=2

And not like you would expect

If a=b Then
a=1
b=2
End if
 

yazak

Member
Licensed User
Longtime User
I am use to using VB6 and Pure Basic
In VB6 anything on same line after Then including colon is part of the Then

In Pure Basic
there is know Then in If 's and you have to end If 's with EndIf
Pure Basic example: If a=b : a=1 : b=2 : EndIf
 
Last edited:

nikolaus

Member
Licensed User
Longtime User
Well, this is B4A.

Please checkout the documentation. Anything that works as described is a feature. Only if it behaves different from how it should, it is a bug.

If you think a feature needs improvement then post a whish.
 

Del

Member
Licensed User
Longtime User
"In VB6 anything on same line after Then including colon is part of the Then"

This is incorrect for VB versions.

If a=b then a=1 : b=2 : End If does not even compile.
 

yazak

Member
Licensed User
Longtime User
Of course not you have put a End if on single line If Then

Should be for VB6

If a=b then a=1 : b=2

Or multi line like this

If a=b Then
a=1
b=2
End if

By the way I am not concerned about the difference in B4A I was just pointing it out so users of VB6 are aware of the differences, as I could not at first work out why some of my code was not working as expected.
 
Top