Friday, July 8, 2016

IDP2 - Activity #3

GUI:


Source Code:

Option Explicit

Dim StrHeight As Integer
Dim StrWidth As Integer
Dim FormHeight As Integer
Dim FormWidth As Integer


Private Sub Form_Load()
    StrHeight = Label1.Height
    StrWidth = Label1.Width
    
    FormHeight = Form1.ScaleHeight
    FormWidth = Form1.ScaleWidth
    
    Timer1.Enabled = True
    Timer2.Enabled = False
    
    Timer1.Interval = 50
    Timer2.Interval = 50
    
    Call ResetStr
End Sub

Private Sub ResetStr()
    Label1.Top = 0
    Label1.Left = 0
End Sub

Private Sub Timer1_Timer()
    If Label1.Left <= (FormWidth - StrWidth) Then
        Label1.Left = Label1.Left + 100
    Else
        Timer1.Enabled = False
        Timer2.Enabled = True
    End If
End Sub

Private Sub Timer2_Timer()
    If Label1.Top <= (FormHeight - StrHeight) Then
        Label1.Top = Label1.Top + 50
    Else
        Timer2.Enabled = False
        'Timer3.Enabled = True
    End If
End Sub

--------------------------------------

Objective:

Append the program and add the functionality to complete the cycle of the moving label. Make sure that the label will keep on rotating until such time the user interferes and stop the program.