Professor Joy: CMSC222 Class Work
Animals in Array
At the start there are no animals in the array. We can add animals. After we add the first animal we enable the timer. When the timer goes off, the nextr animal is displayed in the text.
Public Class Form1
Dim animals(0) As String
Dim Num As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Num = Num + 1
If Num >= animals.Length - 1 Then
Num = 0
End If
Me.Text = animals(Num)
End Sub
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
Dim A As String = InputBox("Name an animal", "Add")
Dim N As Integer
If A <> "" Then
N = animals.Length
ReDim Preserve animals(N)
animals(N - 1) = A
Me.Timer1.Enabled = True
End If
End Sub
End Class
This web site, and all pages therein, are the sole property and responsibility of Zebra0.com.
It is not endorsed, sponsored, or provided by or on behalf of Montgomery College.