Database development and training for Birmingham and the midlands
Specialists in Microsoft Access and Visual Foxpro database training and development
I am happy to hear from existing clients but I am taking no new calls.
Visual Basic and Visual FoxPro If ... Else statements
VBAIf, Then, Else, ElseIf, End If |
VFPIf, Else, EndIf |
Common Syntax Notes
The syntax is almost identical in the two languages. This example is Visual Basic
If a > b Then
c = "Bigger"
Else
c = "Smaller"
End If
c = "Bigger"
Else
c = "Smaller"
End If
and this is the same snippet in Visual FoxPro:
If a > b Then
c = "Bigger"
Else
c = "Smaller"
EndIf
c = "Bigger"
Else
c = "Smaller"
EndIf
You can only see one infuriating difference, I have been careful to avoid the other:
- Visual Basic insists on having a Then after the If whereas it's optional in Visual FoxPro.
- Visual Basic has End If as two words whereas it's the single word EndIf in Visual FoxPro. What's worse is that VB will automatically correct you if you type EndIf by mistake but, despite having Intellisense, FoxPro won't. I suppose I should add this as a custom feature to my own Intellisense table.
Apart from that, VBA allows multiple clauses to be chained together with ElseIf where FoxPro would use its Do Case structure.