Segmented Control Error

Hello,

i try to insert different values on a webapp.
A slider doesn’t work (on android) so i try it with segmented controls with + and - buttons.
But there is a strange error!
I place a label and a segmentedcontrol on a webpage.
Left button is “-”
Right button is “+”
Label1.text = str(Index)
That works!

But if i use the segmentedcontrol as a new controlset (i need a lot of segmentedcontrols) it stops on runtime with a bug on the Label1.text = str(Index) without further informations.

What’s going wrong?

Could you show us the actual code that you are using?

Thats all:

Sub Action(index as Integer, SegmentIndex As Integer)
'Label1.Text = Str(Index)
Label1.Text = Str(SegmentIndex)
End Sub

It looks to me like it is stopping on this line with a NilObjectException (you should be able to see it in the debugger):

Label1.Text = Str(SegmentIndex)

The only thing that could be Nil there is Label1 so perhaps this Action even is being called before Label1 is actually created on the page.

Checking for Nil is a solution:

If Label1 <> Nil Then Label1.Text = Str(SegmentIndex) End If

Crazy. That works.! Thanks!
But there is no action event. The error is during the start.
It’s a bug or a feature?

Right. The startup is calling the Action event for some reason. Perhaps it getting called because one of the segments is set as the default and when it attempts to set it at startup it calls the Action event handler.

It seems unexpected. Fortunately the workaround is pretty simple. You can create a Feedback case for this if it is important enough for you.