Tshenolo2022
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 = Colors.red
Case "G"
lblColor.text = firstchar
lblColor.color = Colors.GREEN
Case "M"
lblColor.text = firstchar
lblColor.color = Colors.Blue
End Select
End Sub
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 = Colors.red
Case "G"
lblColor.text = firstchar
lblColor.color = Colors.GREEN
Case "M"
lblColor.text = firstchar
lblColor.color = Colors.Blue
End Select
End Sub