这个是我们老师做的,代码是对的,但放到有写机子上无法运行
选号小助手
窗体1
Option Explicit
Private Sub Command1_Click()
Dim i As Integer, j As Integer, d As Integer
Dim a As String
d = 1
For i = 0 To 34
Text1(i).Text = Mid$(GenNnm, d, 2)
d = d + 2
Next i
'1-7排序并去初重复
aa:
For i = 1 To 6
For j = 0 To i
If Val(Text1(j).Text) > Val(Text1(i).Text) Then
a = Text1(i).Text
Text1(i).Text = Text1(j).Text
Text1(j).Text = a
End If
Next j
Next i
For j = 0 To 6
If Val(Text1(j).Text) = Val(Text1(j + 1).Text) Then
d = 1
For i = 0 To 6
Text1(i).Text = Mid$(GenNnm, d, 2)
d = d + 2
Next i
GoTo aa
End If
Next j
'7-14排序并去处重复
bb:
For i = 8 To 13
For j = 7 To i
If Val(Text1(j).Text) < Val(Text1(i).Text) Then
a = Text1(i).Text
Text1(i).Text = Text1(j).Text
Text1(j).Text = a
End If
Next j
Next i
For j = 7 To 13
If Val(Text1(j).Text) = Val(Text1(j + 1).Text) Then
d = 15
For i = 7 To 13
Text1(i).Text = Mid$(GenNnm, d, 2)
d = d + 2
Next i
GoTo bb
End If
Next j
'14-21排序并去处重复
cc:
For i = 15 To 20
For j = 14 To i
vb所有代码 If Val(Text1(j).Text) < Val(Text1(i).Text) Then
a = Text1(i).Text
Text1(i).Text = Text1(j).Text
Text1(j).Text = a
End If
Next j
Next i
For j = 14 To 20
If Val(Text1(j).Text) = Val(Text1(j + 1).Text) Then
d = 29
For i = 14 To 20
Text1(i).Text = Mid$(GenNnm, d, 2)
d = d + 2
Next i
GoTo cc
End If
Next j
'21-28排序
dd:
For i = 22 To 27
For j = 21 To i
If Val(Text1(j).Text) < Val(Text1(i).Text) Then
a = Text1(i).Text
Text1(i).Text = Text1(j).Text
Text1(j).Text = a
End If
Next j
Next i
For j = 21 To 27
If Val(Text1(j).Text) = Val(Text1(j + 1).Text) Then
d = 43
For i = 21 To 27
Text1(i).Text = Mid$(GenNnm, d, 2)
d = d + 2
Next i
GoTo dd
End If
Next j
'28-35排序并去处重复
ee:
For i = 29 To 34
For j = 28 To i
If Val(Text1(j).Text) < Val(Text1(i).Text) Then
a = Text1(i).Text
Text1(i).Text = Text1(j).Text
Text1(j).Text = a
End If
Next j
Next i
For j = 28 To 33
If Val(Text1(j).Text) = Val(Text1(j + 1).Text) Then
d = 55
For i = 28 To 34
Text1(i).Text = Mid$(GenNnm, d, 2)
d = d + 2
Next i
GoTo ee
End If
Next j
End Sub
Function GenNnm() As String
Dim str1 As String
Dim i As Integer, Num As Integer
Dim usechar As String
usechar = "0102030405060708091011121314151617181920212223242526272829303132333435"
str1 = ""
Randomize
For i = 1 To 36
Num = Len(usechar) * Rnd + 1
If Num Mod 2 = 1 Then
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论