T Tshenolo2022 New Member Apr 25, 2024 #1 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
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
josejad Expert Licensed User Longtime User Apr 25, 2024 #2 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: Apr 25, 2024 Upvote 1
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