Private Sub Command1_Click()
Label1.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
Label2.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
Label3.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
Label4.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
Label5.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
Label6.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
Label7.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
End SubPrivate Sub Command2_Click()
End
End SubPrivate Sub Command3_Click()
Label1.Caption = " "
Label2.Caption = " "
Label3.Caption = " "
Label4.Caption = " "
Label5.Caption = " "
Label6.Caption = " "
Label7.Caption = " "
End SubPrivate Sub Form_Load()
Label1.Caption = " "
Label2.Caption = " "
Label3.Caption = " "
Label4.Caption = " "
Label5.Caption = " "
Label6.Caption = " "
Label7.Caption = "特殊号码"
End Sub是个生成彩票的程序
怎么让随机生成的数字不一样???

解决方案 »

  1.   

    Private Sub Command1_Click()
    Randomize '加这句
    Label1.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
    Label2.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
    Label3.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
    Label4.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
    Label5.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
    Label6.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
    Label7.Caption = Fix(Rnd * (0 - 33 + 1)) + 33
    End Sub
      

  2.   

    果然很象第一次写的程序,改用控件数组吧,选中LABEL1按“CTRL+C”再点窗体空白处按“CTRL+C”,VB就会帮你创建控件数组了。Private Sub Command1_Click()
    Dim I as Long 
    For I =0 to label1.count-1
       Label1(I).Caption = Fix(Rnd * 33) '你真的不知道Fix(Rnd*(0-33+1))+33是几么?
    Next
    End SubPrivate Sub Command2_Click()
    Unload Me '即使要写End也放到Form_Unload事件中写,养成好习惯。
    End SubPrivate Sub Command3_Click()
    Dim I as Long
    For I=0 to label1(I).count-1
       Label1(I).Caption=""
    Next
    End SubPrivate Sub Form_Load()
    Dim I as Long 
    For I=0 to Label1.Count-2
       Label1(I).Caption = ""
    Next
    Label1(I).Caption = "特殊号码"
    End Sub能自己算的,别都交给CPU。
      

  3.   

    控件数组吧,选中LABEL1按“CTRL+C”再点窗体空白处按“CTRL+C”,VB就会帮你创建控件数组了。
      

  4.   

    明目张胆的盗版呀,楼上的太不厚道.一个字也不打,就这么
    选中按“CTRL+C”再点回复处按“CTRL+C”了