Android Question Syntax Error


New Member
I'm getting a syntax error on the bold code when compiling my program. Please kindly assist.
This is the code below.
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private BtnCheck As B4XView
Private EditInput As B4XView
Private lblColor As B4XView
Private lblName As B4XView
End Sub

Private Sub BtnCheck_Click

'Get input from the edit text and pass it to the label
lblName.Text = EditInput.text
End Sub

Sub firstchar As Char

'Grab first character using CharAT
firstchar = lblName.Text.CharAt(0)

'Using Select to determine which color to assign first char
Select firstchar
Case "X"
lblColor.text = firstchar
lblColor.color =
Case "G"
lblColor.text = firstchar
lblColor.color = Colors.GREEN
Case "M"
lblColor.text = firstchar
lblColor.color = Colors.Blue
End Select
End Sub


Licensed User
Longtime User
Please, use [code] ...your code... [/code] tags when pasting code.

The error is because the function name is the same as the var firstchar. Change the name of the variable
Last edited:
Upvote 1