vb中要是循环5个连续的数,然后隔2个再循环5个连续的数,怎么做?

来源:百度知道 编辑:UC知道 时间:2024/06/13 17:38:53

Private Sub Command2_Click()
Dim i As Integer
Dim intStep1 As Integer, intstep2 As Integer

Const int1 As Integer = 5 '循环的数
Const int2 As Integer = 2 '跳过的数

intStep1 = 0
intstep2 = 0

For i = 1 To 100
intStep1 = intStep1 + 1

If intstep2 = 0 And intStep1 <= int1 Then
Print i '循环的内容
Else
intstep2 = intstep2 + 1

If intstep2 = int2 Then
intStep1 = 0
intstep2 = 0
End If
End If
Next
End Sub