Testredim project (Powerpoint redim.ppt)
Public Class
frmTestReDim
Inherits
System.Windows.Forms.Form
Dim accumArray() As Integer
Dim ct As
Integer
Dim wkHowMany As Integer
Dim wkMore
As Integer
Private Sub btnStartGather_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnStartGather.Click
wkHowMany = InputBox("Enter number of original
entries", "Start")
ReDim accumArray(wkHowMany
- 1)
lstOriginal.Items.Add("Entries: " & CStr(accumArray.Length))
ct = 0
btnGatherAmount.Enabled = True
btnClear.Enabled = True
btnStartGather.Enabled = False
txtAmount.Focus()
End Sub
Private Sub btnGatherAmount_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnGatherAmount.Click
accumArray(ct) = CInt(txtAmount.Text)
lstOriginal.Items.Add(accumArray(ct))
ct = ct + 1
btnGatherAmount.Enabled = False
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
btnClear.Click
txtAmount.Clear()
If ct <
accumArray.Length Then
btnGatherAmount.Enabled = True
txtAmount.Focus()
Else
btnClear.Enabled = False
btnContinue.Enabled = True
End If
End Sub
Private Sub btnContinue_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
btnContinue.Click
wkMore = InputBox("How many more do you want to
enter", "Continue Array")
ReDim Preserve accumArray(wkHowMany - 1 + wkMore)
lstSecond.Items.Add("Entries: " & CStr(accumArray.Length))
btnContGather.Enabled = True
btnClearSecond.Enabled = True
End Sub
Private Sub btnContGather_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnContGather.Click
accumArray(ct) = CInt(txtAmountSecond.Text)
lstSecond.Items.Add(accumArray(ct))
ct = ct + 1
btnContGather.Enabled = False
End
Sub
Private Sub btnClearSecond_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnClearSecond.Click
txtAmountSecond.Clear()
If ct <
accumArray.Length Then
btnContGather.Enabled = True
txtAmountSecond.Focus()
Else
btnShowContents.Enabled = True
End If
End Sub
Private Sub btnShowContents_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnShowContents.Click
Dim i As Integer
For i = 0 To accumArray.Length - 1
lstShowArray.Items.Add(accumArray(i))
Next
End Sub
End Class