⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formball.frm

📁 利用随机函数自动产生随机数后自动排序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FormBall 
   Caption         =   "FormBall"
   ClientHeight    =   4290
   ClientLeft      =   60
   ClientTop       =   420
   ClientWidth     =   4365
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   4290
   ScaleWidth      =   4365
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton CmdOutput 
      Caption         =   "导出列表"
      Height          =   375
      Left            =   3000
      TabIndex        =   17
      Top             =   2640
      Width           =   975
   End
   Begin VB.CommandButton CmdListClear 
      Caption         =   "清空列表"
      Height          =   375
      Left            =   3000
      TabIndex        =   16
      Top             =   2160
      Width           =   975
   End
   Begin VB.Frame Frame2 
      Caption         =   "自动生成"
      Height          =   855
      Left            =   120
      TabIndex        =   11
      Top             =   1080
      Width           =   4095
      Begin VB.TextBox TextAuto 
         Height          =   375
         Left            =   1920
         TabIndex        =   15
         Text            =   "10"
         Top             =   240
         Width           =   735
      End
      Begin VB.CommandButton CmdQuick 
         Caption         =   "自动生成"
         Height          =   375
         Left            =   2880
         TabIndex        =   14
         Top             =   240
         Width           =   975
      End
      Begin VB.OptionButton OptMode 
         Caption         =   "追加"
         Height          =   255
         Index           =   1
         Left            =   960
         TabIndex        =   13
         Top             =   360
         Width           =   735
      End
      Begin VB.OptionButton OptMode 
         Caption         =   "覆盖"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   12
         Top             =   360
         Value           =   -1  'True
         Width           =   735
      End
   End
   Begin VB.ListBox ListBall 
      Height          =   1860
      Left            =   120
      TabIndex        =   10
      Top             =   2160
      Width           =   2415
   End
   Begin VB.Frame Frame1 
      Caption         =   "手动生成"
      Height          =   855
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4095
      Begin VB.CommandButton CmdRnd 
         Caption         =   "随机产生"
         Height          =   375
         Left            =   2880
         TabIndex        =   8
         Top             =   240
         Width           =   975
      End
      Begin VB.TextBox TextBall 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         Height          =   375
         Index           =   0
         Left            =   120
         TabIndex        =   7
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox TextBall 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         Height          =   375
         Index           =   1
         Left            =   480
         TabIndex        =   6
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox TextBall 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         Height          =   375
         Index           =   2
         Left            =   840
         TabIndex        =   5
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox TextBall 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         Height          =   375
         Index           =   3
         Left            =   1200
         TabIndex        =   4
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox TextBall 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         Height          =   375
         Index           =   4
         Left            =   1560
         TabIndex        =   3
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox TextBall 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         Height          =   375
         Index           =   5
         Left            =   1920
         TabIndex        =   2
         Top             =   240
         Width           =   375
      End
      Begin VB.TextBox TextBall 
         Alignment       =   2  'Center
         Enabled         =   0   'False
         Height          =   375
         Index           =   6
         Left            =   2400
         TabIndex        =   1
         Top             =   240
         Width           =   375
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         Caption         =   "-"
         Enabled         =   0   'False
         Height          =   255
         Left            =   2280
         TabIndex        =   9
         Top             =   360
         Width           =   135
      End
   End
   Begin VB.Label LabelListCount 
      Alignment       =   2  'Center
      Caption         =   "0"
      ForeColor       =   &H00C00000&
      Height          =   375
      Left            =   3000
      TabIndex        =   18
      Top             =   3480
      Width           =   855
   End
End
Attribute VB_Name = "FormBall"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim BallBlue(16) As Integer
Dim BallRed(33) As Integer

Private Sub CmdListClear_Click()
    ListBall.Clear
    LabelListCount.Caption = ListBall.ListCount
End Sub

Private Sub CmdOutput_Click()

    Dim FcInfo As String
    Dim i As Long

    Open App.Path & "\List.txt" For Output As 1

    For i = 0 To ListBall.ListCount
        FcInfo = ListBall.List(i)
        Print #1, FcInfo
    Next

    Close #1
    
End Sub

Private Sub CmdQuick_Click()

    Dim i As Integer
    If OptMode(0).Value = True Then
        ListBall.Clear
    End If
    For i = 0 To Val(TextAuto.Text) - 1
        Call CmdRnd_Click
    Next

    ListBall.ListIndex = ListBall.ListCount - 1
    LabelListCount.Caption = ListBall.ListCount
End Sub

Private Sub CmdRnd_Click()
    Dim i, j, k As Integer
    Dim UpperBound As Integer
    Dim BallNum As Integer
    Dim tempstring As String
    
    For i = 0 To 32
        BallRed(i) = i + 1
        If i < 16 Then
            BallBlue(i) = i + 1
        End If
    Next
    
    tempstring = ""
    UpperBound = 32
    BallNum = 0
    
    For k = 0 To 5
        Randomize
        i = UpperBound * Rnd
        
        If BallRed(i) < 10 Then
            TextBall(BallNum).Text = "0" & BallRed(i)
        Else
            TextBall(BallNum).Text = BallRed(i)
        End If
        
        For j = i To UpperBound
            BallRed(j) = BallRed(j + 1)
        Next
        
        UpperBound = UpperBound - 1
        BallNum = BallNum + 1
    Next
    
    Randomize
    i = 15 * Rnd
    If BallBlue(i) < 10 Then
        TextBall(6).Text = "0" & BallBlue(i)
    Else
        TextBall(6).Text = BallBlue(i)
    End If
    
    Call Sequencing
    
    For i = 0 To 5
        tempstring = tempstring & TextBall(i).Text & " "
    Next
    tempstring = tempstring & "- " & TextBall(6).Text
    
    ListBall.AddItem (tempstring)

    ListBall.ListIndex = ListBall.ListCount - 1
    LabelListCount.Caption = ListBall.ListCount
End Sub


Private Sub Sequencing()
    Dim i, j, TempInt As Variant

    For i = 0 To 4
        For j = 0 To 4 - i
            If Val(TextBall(j).Text) > Val(TextBall(j + 1).Text) Then
                TempInt = TextBall(j).Text
                TextBall(j).Text = TextBall(j + 1).Text
                TextBall(j + 1).Text = TempInt
            End If
        Next
    Next
    
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -