66 lines
3.6 KiB
Text
66 lines
3.6 KiB
Text
'This code will create the necessary controls on a GUI Form
|
|
|
|
hLabel As Label 'Label needed to display the 'Hello World! " message
|
|
hTimer As Timer 'Timer to rotate the display
|
|
bDirection As Boolean 'Used to control the direction of the text
|
|
'__________________________________________________
|
|
Public Sub Form_Open()
|
|
Dim hPanel As Panel '2 Panels used to centre the Label vertically on the Form
|
|
Dim hHBox As HBox 'Box to hold the Label
|
|
|
|
With Me 'Set the Form Properties
|
|
.Arrangement = Arrange.Vertical 'Arrange controls vertically
|
|
.Title = "Animation" 'Give the Form a Title
|
|
.Height = 75 'Set the Height of the Form
|
|
.Width = 225 'Set the Width of the Form
|
|
End With
|
|
|
|
hPanel = New Panel(Me) 'Add a Panel to the Form
|
|
HPanel.Expand = True 'Expand the Panel
|
|
|
|
hHBox = New HBox(Me) 'Add a HBox to the Form
|
|
hHBox.Height = 28 'Set the HBox Height
|
|
|
|
hLabel = New Label(hHBox) As "LabelAnimation" 'Add new Lable with Event name
|
|
|
|
With hLabel 'Change the hLabel properties
|
|
.Height = 35 'Set the Height of the Label
|
|
.Expand = True 'Expand the hLabel
|
|
.Font.Bold = True 'Set the Font to Bold
|
|
.Font.size = 20 'Set the Font Size
|
|
.Alignment = Align.Center 'Centre align the text
|
|
.Tooltip = "Click me to reverse direction" 'Add a Tooltip
|
|
.Border = Border.Plain 'Add a Border
|
|
.Text = "Hello World! " 'Add the Text
|
|
End With
|
|
|
|
hPanel = New Panel(Me) 'Add another Panel
|
|
HPanel.Expand = True 'Expand the Panel
|
|
|
|
hTimer = New Timer As "Timer1" 'Add a Timer
|
|
hTimer.delay = 500 'Set the Timer Delay
|
|
hTimer.Start 'Start the Timer
|
|
|
|
End
|
|
'__________________________________________________
|
|
Public Sub LabelAnimation_MouseDown() 'If the hLabel is clicked..
|
|
|
|
bDirection = Not bDirection 'Change the value of bDirection
|
|
|
|
End
|
|
'__________________________________________________
|
|
Public Sub Timer1_Timer() 'Timer
|
|
Dim sString As String = hLabel.Text 'To hold the text in the Label
|
|
Dim sTemp As String 'Temp string
|
|
|
|
If bDirection Then 'If the text is to rotate left then..
|
|
sTemp = Left(sString, 1) 'Get the first charater of the Label Text e.g 'H'
|
|
sString = Right(sString, -1) & sTemp 'Recreate sString with all the text less the 1st character e.g. 'ello World! ' and add the 1st character to the end e.g. 'ello World! H'
|
|
Else 'Else if text is to rotate right then..
|
|
sTemp = Right(sString, 1) 'Get the last charater of the Label Text e.g '!'
|
|
sString = sTemp & Left(sString, -1) 'Recreate sString with all the text less the last character e.g. ' Hello World' and add the last character to the begining e.g. '! Hello World'
|
|
End If
|
|
|
|
hLabel.text = sString 'Display the result
|
|
|
|
End
|