The ButtonClick event should be captured in a subroutine and processed via a variable in the main program.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm Playing around with small basic and I'm trying to add two Buttons at the end of the program, but these don't do anything. I currently only know how to do things with If- and while-loops.
This is the code:
ButtonRestart = Controls.AddButton("Restart", 10, 10)
ButtonExit = Controls.AddButton("Exit", 90, 10)
Controls.SetSize(ButtonRestart, 70, 26)
Controls.SetSize(ButtonExit, 70, 26)
If Controls.LastClickedButton = ButtonRestart Then
GraphicsWindow.Clear()
GraphicsWindow.Hide()
Goto Start
ElseIf Controls.LastClickedButton = ButtonExit Then
GraphicsWindow.Hide()
Program.End()
EndIf
The ButtonClick event should be captured in a subroutine and processed via a variable in the main program.
To make it easier for someone to use your program it is better to publish it as code instead as an image:
Use the fifth button on the top of the answerform ( marked with 001 010 ) It is then easy to copy.
GraphicsWindow.Title = "Buttonloop"
GraphicsWindow.Width = 400
GraphicsWindow.Height = 200
ON = Controls.AddButton("ON",10,20)
OFF = Controls.AddButton("OFF",200,20)
Controls.ButtonClicked = buttonclicked
End=0
While End = 0
If BC=1 Then
BC = 0
lastbutton = Controls.LastClickedButton
If lastbutton = OFF Then
End = 1
ElseIf lastbutton = ON Then
GraphicsWindow.ShowMessage("You pressed ON","Answer")
EndIf
EndIf
EndWhile
Program.End()
Sub buttonclicked
BC = 1
EndSub