# 气死我了，快拉兄弟一把！

Posted by 八戒 on April 28, 1999 at 01:33:41:

八戒刚出家，第一次来，给各位问好！

八戒想发□，用VB做个六合彩的?测器。用个Label array分别□示7个从1 - 49的数。但数字不能□复(repeat)，即每个数只能用一次。

写了段code, 不知为何，数字不□复没能实现。哪位大师给看看是什么毛病？

The code is as following:

Private Sub Command1_Click()
Dim iLuckyNumber As Integer
Dim i As Integer
Dim j As Integer
For i = 0 To 6
Label1(i) = "" 'clear all numbers to zero at beginning"
Next i

For i = 0 To 6 'allocate numbers to 7 labels
Do While iLuckyNumber < 1 Or iLuckyNumber > 49 'number must be between 1 and 49
iLuckyNumber = Int(Rnd * 100)
Loop
For j = 0 To i 'compare iLuckyNumber with numbers on previous labels
If iLuckyNumber = Val(Label1(j).Caption) Then 'if new number is the same as previous, reset i=i-1 to do it again
i = i - 1
End If
Next j
Label1(i).Caption = iLuckyNumber
iLuckyNumber = 0
Next i
Randomize
End Sub

Follow Ups:

- Re: 气死我了，快拉兄弟一把！ Knight 10:05:31 5/03/99 (0)
- Re: 气死我了，快拉兄弟一把！ 纪文和 14:10:42 4/28/99 (1)
  - Re: 气死我了，快拉兄弟一把！ 八戒 22:16:41 4/28/99 (0)