Dim oldArr%() = {1, 3, 4, 5, 0, 0, 6, 6, 0, 5, 4, 7, 6, 7, 0, 5}
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim i%, newArr%()
Dim count% = -1
Dim tmp As String = String.Empty
For i = 0 To oldArr.GetUpperBound(0)
If oldArr(i) <> 0 Then
count += 1
ReDim Preserve newArr(count)
newArr(count) = oldArr(i)
tmp += oldArr(i).ToString() + ", "
End If
Next
TextBox2.Text = Mid(tmp, 1, Len(tmp) - 2)
End Sub
Dim total(,) As Integer = New Integer(,) _
{
{20, 80, 60, 70, 90, 30, 0},
{50, 50, 60, 30, 80, 50, 0},
{80, 20, 30, 70, 70, 90, 0},
{40, 80, 60, 20, 80, 50, 0},
{30, 10, 20, 70, 10, 90, 0}
}
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim cnt As Integer = 0
Dim tmp As String = String.Empty
For i = 0 To total.GetUpperBound(0)
cnt = 0
tmp = String.Empty
For j = 0 To total.GetUpperBound(1) - 1
cnt += total(i, j)
tmp += total(i, j).ToString() + " "
Next
total(i, total.GetUpperBound(1)) = cnt
TextBox1.Text = TextBox1.Text +
tmp.ToString()& " " &
Int((cnt / 6).ToString()) & vbCrLf
Next
End Sub