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

📄 random.frm

📁 大量优秀的vb编程
💻 FRM
字号:
VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmRandom 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "随机数产生器"
   ClientHeight    =   4932
   ClientLeft      =   48
   ClientTop       =   336
   ClientWidth     =   7920
   Icon            =   "Random.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4932
   ScaleWidth      =   7920
   StartUpPosition =   3  '窗口缺省
   Begin TabDlg.SSTab SSTRandom 
      Height          =   4695
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   7695
      _ExtentX        =   13568
      _ExtentY        =   8276
      _Version        =   393216
      Tab             =   1
      TabHeight       =   520
      TabCaption(0)   =   "混合方法"
      TabPicture(0)   =   "Random.frx":030A
      Tab(0).ControlEnabled=   0   'False
      Tab(0).Control(0)=   "Label1"
      Tab(0).Control(1)=   "Label2"
      Tab(0).Control(2)=   "Label3"
      Tab(0).Control(3)=   "Label6"
      Tab(0).Control(4)=   "txtA1"
      Tab(0).Control(5)=   "txtB1"
      Tab(0).Control(6)=   "txtM1"
      Tab(0).Control(7)=   "txtPrevious1"
      Tab(0).Control(8)=   "cmdMixed"
      Tab(0).Control(9)=   "txtRandom1"
      Tab(0).Control(10)=   "Frame1"
      Tab(0).ControlCount=   11
      TabCaption(1)   =   "乘同余法"
      TabPicture(1)   =   "Random.frx":0326
      Tab(1).ControlEnabled=   -1  'True
      Tab(1).Control(0)=   "Label5"
      Tab(1).Control(0).Enabled=   0   'False
      Tab(1).Control(1)=   "Label8"
      Tab(1).Control(1).Enabled=   0   'False
      Tab(1).Control(2)=   "Label10"
      Tab(1).Control(2).Enabled=   0   'False
      Tab(1).Control(3)=   "txtRandom2"
      Tab(1).Control(3).Enabled=   0   'False
      Tab(1).Control(4)=   "cmdMultiplicative"
      Tab(1).Control(4).Enabled=   0   'False
      Tab(1).Control(5)=   "txtPrevious2"
      Tab(1).Control(5).Enabled=   0   'False
      Tab(1).Control(6)=   "txtM2"
      Tab(1).Control(6).Enabled=   0   'False
      Tab(1).Control(7)=   "txtA2"
      Tab(1).Control(7).Enabled=   0   'False
      Tab(1).Control(8)=   "Frame2"
      Tab(1).Control(8).Enabled=   0   'False
      Tab(1).ControlCount=   9
      TabCaption(2)   =   "加同余法"
      TabPicture(2)   =   "Random.frx":0342
      Tab(2).ControlEnabled=   0   'False
      Tab(2).Control(0)=   "Label9"
      Tab(2).Control(1)=   "Label12"
      Tab(2).Control(2)=   "Label13"
      Tab(2).Control(3)=   "txtRandom3"
      Tab(2).Control(4)=   "cmdAdditive"
      Tab(2).Control(5)=   "txtPrevious3"
      Tab(2).Control(6)=   "txtM3"
      Tab(2).Control(7)=   "txtB3"
      Tab(2).Control(8)=   "Frame3"
      Tab(2).ControlCount=   9
      Begin VB.Frame Frame3 
         Caption         =   "公式"
         Height          =   1335
         Left            =   -74520
         TabIndex        =   29
         Top             =   3000
         Width           =   5655
         Begin VB.Image Image3 
            BorderStyle     =   1  'Fixed Single
            Height          =   744
            Left            =   240
            Picture         =   "Random.frx":035E
            Top             =   240
            Width           =   4224
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "公式"
         Height          =   1335
         Left            =   480
         TabIndex        =   28
         Top             =   3000
         Width           =   5655
         Begin VB.Image Image2 
            BorderStyle     =   1  'Fixed Single
            Height          =   744
            Left            =   240
            Picture         =   "Random.frx":F028
            Top             =   240
            Width           =   4224
         End
      End
      Begin VB.Frame Frame1 
         Caption         =   "公式"
         Height          =   1335
         Left            =   -74520
         TabIndex        =   27
         Top             =   3000
         Width           =   5655
         Begin VB.Image Image1 
            BorderStyle     =   1  'Fixed Single
            Height          =   744
            Left            =   240
            Picture         =   "Random.frx":1DCF2
            Top             =   240
            Width           =   4224
         End
      End
      Begin VB.TextBox txtB3 
         Height          =   285
         Left            =   -73440
         TabIndex        =   23
         Text            =   "18"
         Top             =   1080
         Width           =   2535
      End
      Begin VB.TextBox txtM3 
         Height          =   285
         Left            =   -73440
         TabIndex        =   22
         Text            =   "23"
         Top             =   1560
         Width           =   2535
      End
      Begin VB.TextBox txtPrevious3 
         Height          =   285
         Left            =   -69480
         TabIndex        =   21
         Text            =   "1"
         Top             =   600
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.CommandButton cmdAdditive 
         Caption         =   "产生"
         Height          =   375
         Left            =   -70560
         TabIndex        =   20
         Top             =   1440
         Width           =   1695
      End
      Begin VB.TextBox txtRandom3 
         Height          =   285
         Left            =   -72720
         TabIndex        =   19
         Top             =   2400
         Width           =   3615
      End
      Begin VB.TextBox txtA2 
         Height          =   285
         Left            =   1560
         TabIndex        =   15
         Text            =   "16"
         Top             =   600
         Width           =   2535
      End
      Begin VB.TextBox txtM2 
         Height          =   285
         Left            =   1560
         TabIndex        =   14
         Text            =   "23"
         Top             =   1560
         Width           =   2535
      End
      Begin VB.TextBox txtPrevious2 
         Height          =   285
         Left            =   5520
         TabIndex        =   13
         Text            =   "1"
         Top             =   600
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.CommandButton cmdMultiplicative 
         Caption         =   "产生"
         Height          =   375
         Left            =   4440
         TabIndex        =   12
         Top             =   1440
         Width           =   1695
      End
      Begin VB.TextBox txtRandom2 
         Height          =   285
         Left            =   2280
         TabIndex        =   11
         Top             =   2400
         Width           =   3615
      End
      Begin VB.TextBox txtRandom1 
         Height          =   285
         Left            =   -72720
         TabIndex        =   9
         Top             =   2400
         Width           =   3615
      End
      Begin VB.CommandButton cmdMixed 
         Caption         =   "产生"
         Height          =   375
         Left            =   -70560
         TabIndex        =   8
         Top             =   1440
         Width           =   1695
      End
      Begin VB.TextBox txtPrevious1 
         Height          =   285
         Left            =   -69480
         TabIndex        =   7
         Text            =   "1"
         Top             =   600
         Visible         =   0   'False
         Width           =   495
      End
      Begin VB.TextBox txtM1 
         Height          =   285
         Left            =   -73440
         TabIndex        =   6
         Text            =   "23"
         Top             =   1560
         Width           =   2535
      End
      Begin VB.TextBox txtB1 
         Height          =   285
         Left            =   -73440
         TabIndex        =   4
         Text            =   "18"
         Top             =   1080
         Width           =   2535
      End
      Begin VB.TextBox txtA1 
         Height          =   285
         Left            =   -73440
         TabIndex        =   2
         Text            =   "16"
         Top             =   600
         Width           =   2535
      End
      Begin VB.Label Label13 
         Caption         =   "B ="
         Height          =   375
         Left            =   -74160
         TabIndex        =   26
         Top             =   1080
         Width           =   495
      End
      Begin VB.Label Label12 
         Caption         =   "M ="
         Height          =   375
         Left            =   -74160
         TabIndex        =   25
         Top             =   1560
         Width           =   495
      End
      Begin VB.Label Label9 
         Caption         =   "随机数"
         Height          =   255
         Left            =   -74160
         TabIndex        =   24
         Top             =   2400
         Width           =   1215
      End
      Begin VB.Label Label10 
         Caption         =   "A ="
         Height          =   375
         Left            =   840
         TabIndex        =   18
         Top             =   600
         Width           =   495
      End
      Begin VB.Label Label8 
         Caption         =   "M ="
         Height          =   375
         Left            =   840
         TabIndex        =   17
         Top             =   1560
         Width           =   495
      End
      Begin VB.Label Label5 
         Caption         =   "随机数"
         Height          =   255
         Left            =   840
         TabIndex        =   16
         Top             =   2400
         Width           =   1215
      End
      Begin VB.Label Label6 
         Caption         =   "随机数"
         Height          =   255
         Left            =   -74160
         TabIndex        =   10
         Top             =   2400
         Width           =   1215
      End
      Begin VB.Label Label3 
         Caption         =   "M ="
         Height          =   375
         Left            =   -74160
         TabIndex        =   5
         Top             =   1560
         Width           =   495
      End
      Begin VB.Label Label2 
         Caption         =   "B ="
         Height          =   375
         Left            =   -74160
         TabIndex        =   3
         Top             =   1080
         Width           =   495
      End
      Begin VB.Label Label1 
         Caption         =   "A ="
         Height          =   375
         Left            =   -74160
         TabIndex        =   1
         Top             =   600
         Width           =   495
      End
   End
End
Attribute VB_Name = "frmRandom"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


Private Sub cmdAdditive_Click()
  txtRandom3 = AdditiveRandom(Int(Val(txtB3)), Int(Val(txtM3)), Int(Val(txtPrevious3)))
  txtPrevious3 = txtRandom3
End Sub

Private Sub cmdMixed_Click()
  txtRandom1 = MixedRandom(Int(Val(txtA1)), Int(Val(txtB1)), Int(Val(txtM1)), Int(Val(txtPrevious1)))
  txtPrevious1 = txtRandom1
End Sub


Private Sub cmdMultiplicative_Click()
   txtRandom2 = MultiplicativeRandom(Int(Val(txtA2)), Int(Val(txtM2)), Int(Val(txtPrevious2)))
   txtPrevious2 = txtRandom2
End Sub

Function MultiplicativeRandom(A As Integer, M As Integer, PreviousRandom As Integer) As Integer
  MultiplicativeRandom = (A * PreviousRandom) Mod M
End Function
Function AdditiveRandom(B As Integer, M As Integer, PreviousRandom As Integer) As Integer
  AdditiveRandom = (PreviousRandom + B) Mod M
End Function
Function MixedRandom(A As Integer, B As Integer, M As Integer, PreviousRandom As Integer) As Integer
  MixedRandom = (A * PreviousRandom + B) Mod M
End Function

⌨️ 快捷键说明

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