------------------------------------------------------------------------------------------------
Sub Mult1() ' do while loop
Dim msg As String, i As Integer, j As Integer
i = 1: j = 1
Do While i <= 9
j = 1
Do While j <= 9
msg = msg & j & "*" & i & "=" & i * j & " "
j = j + 1
Loop
msg = msg & vbCrLf
i = i + 1
Loop
MsgBox msg
End Sub
------------------------------------------------------------------------------------------------
Sub Mult2() ' do until loop
Dim msg As String, i As Integer, j As Integer
i = 1: j = 1
Do Until i > 9
j = 1
Do Until j > 9
msg = msg & j & "*" & i & "=" & i * j & " "
j = j + 1
Loop
msg = msg & vbCrLf
i = i + 1
Loop
MsgBox msg
End Sub
------------------------------------------------------------------------------------------------
Sub Mult3() ' do loop while
Dim msg As String, i As Integer, j As Integer
i = 1: j = 1
Do
j = 1
Do
msg = msg & j & "*" & i & "=" & i * j & " "
j = j + 1
Loop While j <= 9
msg = msg & vbCrLf
i = i + 1
Loop While i <= 9
MsgBox msg
End Sub
------------------------------------------------------------------------------------------------
Sub Mult4() ' do loop until
Dim msg As String, i As Integer, j As Integer
i = 1: j = 1
Do
j = 1
Do
msg = msg & j & "*" & i & "=" & i * j & " "
j = j + 1
Loop Until j > 9
msg = msg & vbCrLf
i = i + 1
Loop Until i > 9
MsgBox msg
End Sub
------------------------------------------------------------------------------------------------
Sub Mult5() ' do loop
Dim msg As String, i As Integer, j As Integer
i = 1: j = 1
Do
j = 1
Do
msg = msg & j & "*" & i & "=" & i * j & " "
j = j + 1
If (j = 10) Then
Exit Do
End If
Loop
msg = msg & vbCrLf
i = i + 1
If (i = 10) Then
Exit Do
End If
Loop
MsgBox msg
End Sub
------------------------------------------------------------------------------------------------
Sub Mult6() ' For Next
Dim msg As String, i As Integer, j As Integer
For i = 1 To 9
For j = 1 To 9
msg = msg & j & "*" & i & "=" & i * j & " "
Next
msg = msg & vbCrLf
Next
MsgBox msg
End Sub
------------------------------------------------------------------------------------------------
Sub Mult7() ' While Wend
Dim msg As String, i As Integer, j As Integer
i = 1: j = 1
While i <= 9
j = 1
While j <= 9
msg = msg & j & "*" & i & "=" & i * j & " "
j = j + 1
Wend
msg = msg & vbCrLf
i = i + 1
Wend
MsgBox msg
End Sub
留言列表