GUI component interaction: Difference between revisions
Content added Content deleted
mNo edit summary |
No edit summary |
||
Line 971: | Line 971: | ||
End |
End |
||
</lang> |
</lang> |
||
=={{header|Gambas}}== |
|||
<lang gambas>hValueBox As ValueBox 'We need a ValueBox |
|||
Public Sub Form_Open() |
|||
Dim hButton As Button 'We need 2 Buttons |
|||
With Me 'Set the Form's Properties.. |
|||
.height = 95 'Set the Height |
|||
.Width = 350 'Set the Width |
|||
.Arrangement = Arrange.Vertical 'Arrange items vertically |
|||
.Padding = 5 'Border area |
|||
.Title = "GUI component interaction" 'Title displayed on the Form |
|||
End With |
|||
hValueBox = New ValueBox(Me) 'Add a ValueBox to the Form |
|||
With hValueBox 'Set the ValueBox's Properties.. |
|||
.Expand = True 'Expand the ValueBox |
|||
.Value = 0 'Set it's value to 0 |
|||
End With |
|||
hButton = New Button(Me) As "ButtonInc" 'Add a Button to the form as Event "ButtonInc" |
|||
With hButton 'Set the Button's Properties.. |
|||
.Height = 28 'Set the Height |
|||
.Text = "&Increment" 'Add Text (The '&' adds a keyboard shortcut) |
|||
End With |
|||
hButton = New Button(Me) As "ButtonRand" 'Add a Button to the form as Event "ButtonRand" |
|||
With hButton 'Set the Button's Properties.. |
|||
.Height = 28 'Set the Height |
|||
.Text = "&Random" 'Add Text (The '&' adds a keyboard shortcut) |
|||
End With |
|||
End |
|||
Public Sub ButtonInc_Click() 'When the 'Increment' Button is clicked.. |
|||
hValueBox.Value += 1 'Increase the Value in the ValueBox by 1 |
|||
End |
|||
Public Sub ButtonRand_Click() 'When the 'Random' Button is clicked.. |
|||
Dim siRand As Short 'To store random number |
|||
Dim byAnswer As Byte 'To store the answer to the MessageBox question |
|||
siRand = Rand(1, 32767) 'Create a 'Random' mnumber |
|||
byAnswer = Message.Question("Would you like to set the ValueBox to " & siRand & "?", "Yes", "No") ' Ask if the number is OK |
|||
If byAnswer = 1 Then 'If the user says 'Yes' then |
|||
hValueBox.Value = siRand 'Display the 'Random' number in the ValueBox |
|||
Else 'ELSE |
|||
hValueBox.Value = 0 'Set the ValueBox Value to 0 |
|||
End If |
|||
End</lang> |
|||
=={{header|Haskell}}== |
=={{header|Haskell}}== |