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

📄 form2.frm

📁 随机信号的课程设计
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "生成在[0,1]区间均匀分布的随机数"
   ClientHeight    =   7335
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   9825
   LinkTopic       =   "Form2"
   ScaleHeight     =   7335
   ScaleWidth      =   9825
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command6 
      Caption         =   "抽样数据的仿真"
      Height          =   495
      Left            =   5080
      TabIndex        =   20
      Top             =   6120
      Width           =   1695
   End
   Begin VB.CommandButton Command5 
      Caption         =   "画出均值和方差"
      Height          =   615
      Left            =   6840
      TabIndex        =   18
      Top             =   3360
      Width           =   2775
   End
   Begin VB.CommandButton Command4 
      Caption         =   "返回首页"
      Height          =   495
      Left            =   7560
      TabIndex        =   17
      Top             =   6120
      Width           =   1335
   End
   Begin VB.CommandButton Command3 
      Caption         =   "随机信号的仿真"
      Height          =   495
      Left            =   2600
      TabIndex        =   16
      Top             =   6120
      Width           =   1695
   End
   Begin VB.CommandButton Command2 
      Caption         =   "高斯分布"
      Height          =   495
      Left            =   480
      TabIndex        =   15
      Top             =   6120
      Width           =   1335
   End
   Begin VB.PictureBox Picture2 
      Height          =   1935
      Left            =   240
      ScaleHeight     =   3.307
      ScaleMode       =   7  'Centimeter
      ScaleWidth      =   11.139
      TabIndex        =   12
      Top             =   840
      Width           =   6375
   End
   Begin VB.CommandButton Command1 
      Caption         =   "产生"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   8160
      TabIndex        =   11
      Top             =   360
      Width           =   1215
   End
   Begin VB.TextBox Text3 
      Alignment       =   2  'Center
      Height          =   375
      Left            =   7560
      TabIndex        =   9
      Top             =   2160
      Width           =   2055
   End
   Begin VB.TextBox Text4 
      Height          =   375
      Left            =   7560
      TabIndex        =   8
      Top             =   2760
      Width           =   2055
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   7560
      TabIndex        =   6
      Top             =   1560
      Width           =   2055
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   7560
      TabIndex        =   4
      Top             =   960
      Width           =   2055
   End
   Begin VB.TextBox Text5 
      Height          =   375
      Left            =   7080
      TabIndex        =   2
      Top             =   360
      Width           =   735
   End
   Begin VB.PictureBox Picture1 
      Height          =   1935
      Left            =   240
      ScaleHeight     =   3.307
      ScaleMode       =   7  'Centimeter
      ScaleWidth      =   11.139
      TabIndex        =   0
      Top             =   3480
      Width           =   6375
   End
   Begin VB.Label Label5 
      Caption         =   $"Form2.frx":0000
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1695
      Left            =   6840
      TabIndex        =   19
      Top             =   4200
      Width           =   2895
   End
   Begin VB.Label Label10 
      Caption         =   "产生在[0,1]区间均匀分布的随机数"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1560
      TabIndex        =   14
      Top             =   3000
      Width           =   3735
   End
   Begin VB.Label Label8 
      Caption         =   "对应的波形图"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2520
      TabIndex        =   13
      Top             =   5640
      Width           =   1455
   End
   Begin VB.Label Label3 
      Caption         =   "均值"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6840
      TabIndex        =   10
      Top             =   2280
      Width           =   495
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      Caption         =   "方差"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6720
      TabIndex        =   7
      Top             =   2880
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "最小值"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6720
      TabIndex        =   5
      Top             =   1680
      Width           =   735
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "最大值"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   6720
      TabIndex        =   3
      Top             =   1080
      Width           =   735
   End
   Begin VB.Label Label9 
      Caption         =   "请输入要产生均匀分布随机数的个数,然后单击“产生”按钮"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   1
      Top             =   360
      Width           =   6615
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Label6_Click()

End Sub

Private Sub Command1_Click()
Dim x(100000) As Double
Dim Y(100000) As Double
Dim w(100000) As Double
Dim v(100000) As Double

Dim e As Integer
Static a As Double
Static b As Double
Static c As Double
Static d As Double
e = 1
n = Val(Text5.Text)
If n < 0 Or n = 0 Then
j = MsgBox("请输入大于0的数", 0, 错误)
If j = 1 Then
Text5.SetFocus
End If
Exit Sub
End If
Picture1.Cls
Picture1.Line (-1, 0)-(10.5, 0)
Picture1.Line (0, -1)-(0, 3)
Picture1.Line (-0.2, 2.8)-(0, 3)
Picture1.Line (0.2, 2.8)-(0, 3)
Picture1.Line (10.3, 0.2)-(10.5, 0)
Picture1.Line (10.3, -0.2)-(10.5, 0)
Picture1.CurrentX = -0.2: Picture1.CurrentY = -0.1: Picture1.Print "0"
Picture1.CurrentX = 10.5: Picture1.CurrentY = 0: Picture1.Print "x"
Picture1.CurrentX = -0.3: Picture1.CurrentY = 3: Picture1.Print "Y"
Picture1.Line (-0.1, 2.5)-(0.1, 2.5)
Picture1.Line (10, 0.1)-(10, -0.1)
Picture1.CurrentX = -0.3: Picture1.CurrentY = 2.6: Picture1.Print "1"
Picture1.CurrentX = 9.8: Picture1.CurrentY = -0.2: Picture1.Print n
Picture2.Cls
Picture2.Line (-1, 0)-(10.5, 0)
Picture2.Line (0, -1)-(0, 3)
Picture2.Line (-0.2, 2.8)-(0, 3)
Picture2.Line (0.2, 2.8)-(0, 3)
Picture2.Line (10.3, 0.2)-(10.5, 0)
Picture2.Line (10.3, -0.2)-(10.5, 0)
Picture2.CurrentX = -0.2: Picture2.CurrentY = -0.1: Picture2.Print "0"
Picture2.CurrentX = 10.5: Picture2.CurrentY = 0: Picture2.Print "x"
Picture2.CurrentX = -0.3: Picture2.CurrentY = 3: Picture2.Print "Y"
Picture2.Line (-0.1, 2.5)-(0.1, 2.5)
Picture2.Line (10, 0.1)-(10, -0.1)
Picture2.CurrentX = -0.3: Picture2.CurrentY = 2.6: Picture2.Print "1"
Picture2.CurrentX = 9.8: Picture2.CurrentY = -0.2: Picture2.Print n
Picture2.Line (0, 2.5)-(10, 2.5)
Randomize
For i = 0 To n - 1
x(i) = Rnd()
Next i
For i = 0 To n - 2
Picture1.Line (i * 10 / (n - 1), x(i) * 2.5)-((i + 1) * 10 / (n - 1), x(i + 1) * 2.5)
Picture2.PSet (i * 10 / (n - 1), x(i) * 2.5), RGB(0, 0, 255)
Picture2.PSet (10, x(n - 1) * 2.5), RGB(0, 0, 255)
Next i
For i = 0 To n - 1
a = a + x(i)
Next i
a = a / n
Text3.Text = a

b = x(0)
For i = 1 To n - 1
If b > x(i) Then
b = x(i)
Else
End If
Next i
Text2.Text = b
c = x(0)
For i = 1 To n - 1
If c < x(i) Then
c = x(i)
Else
End If
Next i
Text1.Text = c
For i = 0 To n - 1
Y(i) = (x(i) - a) * (x(i) - a)
Next i
For i = 0 To n - 1
d = d + Y(i)
Next i
d = d / n
Text4.Text = d
For i = 1 To n - 1
w(0) = x(0)
j = i
e = e + 1
w(i) = ((e - 1) / e) * w(i - 1) + (1 / e) * x(j)
v(i) = ((e - 1) / e) * (v(i - 1) + (1 / e) * (x(i) - w(i - 1)) * (x(i) - w(i - 1)))
Next i
For i = 0 To n - 2
Picture1.Line (i * 10 / (n - 1), w(i) * 2.5)-((i + 1) * 10 / (n - 1), w(i + 1) * 2.5), RGB(255, 255, 0)
Picture1.Line (i * 10 / (n - 1), v(i) * 2.5)-((i + 1) * 10 / (n - 1), v(i + 1) * 2.5), RGB(0, 0, 255)
Next i
Picture1.CurrentX = 10: Picture1.CurrentY = w(n - 1) * 2.5: Picture1.Print "E1"
Picture1.CurrentX = 10: Picture1.CurrentY = v(n - 1) * 2.5: Picture1.Print "D1"
End Sub

Private Sub Command2_Click()
Form3.Show

Unload Form2
End Sub

Private Sub Command3_Click()
Form4.Show

Unload Form2
End Sub

Private Sub Command4_Click()
Form1.Show
Unload Form2
End Sub

Private Sub Command5_Click()
Label5.Visible = True
Picture1.Line (0, Val(Text3.Text) * 2.5)-(10, Val(Text3.Text) * 2.5), RGB(255, 0, 0)
Picture1.CurrentX = 10: Picture1.CurrentY = Val(Text3.Text) * 2.5 + 0.3: Picture1.Print "E2"
Picture1.Line (0, Val(Text4.Text) * 2.5)-(10, Val(Text4.Text) * 2.5), RGB(0, 255, 0)
Picture1.CurrentX = 10: Picture1.CurrentY = Val(Text4.Text) * 2.5 + 0.3: Picture1.Print "D2"
End Sub

Private Sub Command6_Click()
Form5.Show
Unload Form2
End Sub

Private Sub Form_activate()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text5.SetFocus
Label5.Visible = False
Picture1.Cls
Picture2.Cls
Picture1.Scale (-1.5, 3.5)-(11, -1.5)
Picture1.Line (-1, 0)-(10.5, 0)
Picture1.Line (0, -1)-(0, 3)
Picture1.Line (-0.2, 2.8)-(0, 3)
Picture1.Line (0.2, 2.8)-(0, 3)
Picture1.Line (10.3, 0.2)-(10.5, 0)
Picture1.Line (10.3, -0.2)-(10.5, 0)
Picture1.CurrentX = -0.2: Picture1.CurrentY = -0.1: Picture1.Print "0"
Picture1.CurrentX = 10.5: Picture1.CurrentY = 0: Picture1.Print "x"
Picture1.CurrentX = -0.3: Picture1.CurrentY = 3: Picture1.Print "Y"
Picture2.Scale (-1.5, 3.5)-(11, -1.5)
Picture2.Line (-1, 0)-(10.5, 0)
Picture2.Line (0, -1)-(0, 3)
Picture2.Line (-0.2, 2.8)-(0, 3)
Picture2.Line (0.2, 2.8)-(0, 3)
Picture2.Line (10.3, 0.2)-(10.5, 0)
Picture2.Line (10.3, -0.2)-(10.5, 0)
Picture2.CurrentX = -0.2: Picture2.CurrentY = -0.1: Picture2.Print "0"
Picture2.CurrentX = 10.5: Picture2.CurrentY = 0: Picture2.Print "x"
Picture2.CurrentX = -0.3: Picture2.CurrentY = 3: Picture2.Print "Y"
End Sub

⌨️ 快捷键说明

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