分享

用VB编写的双色球选号程序

 hjr231 2019-04-12

         用VB编写的双色球选号程序

程序简要介绍:

    新建一个窗体,在该窗体内放入9个标签控件,其中label2--label8分别放入选出的号码;有一个组合框控件,准备存入每次选中的号码;两个命令按钮,分别为“开始选号”与“退出”。

代码如下:

Option Explicit
Private Sub Command1_Click()    '开始选号
   Dim q As Integer
   Dim a As Integer
   Dim b As Integer
   Dim c As Integer
   Dim d As Integer
   Dim e As Integer
   Dim f As Integer
   Dim g As Integer
  
   For q = 1 To 7
       Select Case q
          Case 1
              Randomize (Time)
              a = Int(Rnd * 33 + 1)
              Label2.Caption = a
         
          Case 2
             Do
                Randomize (Time)
                b = Int(Rnd * 33 + 1)
             Loop Until b <> Label2.Caption
             Label3.Caption = b
            
           Case 3
             Do
                Randomize (Time)
                c = Int(Rnd * 33 + 1)
             Loop Until c <> Label2.Caption And c <> Label3.Caption
             Label4.Caption = c
            
            Case 4
             Do
                Randomize (Time)
                d = Int(Rnd * 33 + 1)
             Loop Until d <> Label2.Caption And d <> Label3.Caption And d <> Label4.Caption
             Label5.Caption = d
  
            Case 5
             Do
                Randomize (Time)
                e = Int(Rnd * 33 + 1)
             Loop Until e <> Label2.Caption And e <> Label3.Caption And e <> Label4.Caption And e <> Label5.Caption
             Label6.Caption = e
  
            Case 6
             Do
                Randomize (Time)
                f = Int(Rnd * 33 + 1)
             Loop Until f <> Label2.Caption And f <> Label3.Caption And f <> Label4.Caption And f <> Label5.Caption And f <> Label6.Caption
             Label7.Caption = f
  
  
            Case 7
               Randomize (Time)
               g = Int(Rnd * 16 + 1)
               Label8.Caption = g
            Case Else
         End Select
      Next q
        
          Dim w  As Variant      '在组合框内添加选出的号码
             w = a & "  " & b & "  " & c & "  " & d & "  " & e & "  " & f & "--" & g
          Combo1.Text = w
          Combo1.AddItem w, 0
         
        
  
  
End Sub

Private Sub Command2_Click()   '退出程序
  End
End Sub

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多