vb中从两个文本框输入两个数(m~n),打印出m~n之间的偶数和

2025-03-15 16:00:19
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim m As Integer, n As Integer
Cls
m = Val(Text1.Text)
n = Val(Text2.Text)
If m > n Then '比较m,n大小,使m小于n
    j = m
    m = n
    n = j
End If
For i = m To n
    If i Mod 2 = 0 Then
        Print i
    End If
Next i
End Sub