📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4395
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4395
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text1
Height = 375
Left = 1800
TabIndex = 6
Top = 960
Width = 2055
End
Begin VB.TextBox Text3
Height = 375
Left = 1800
TabIndex = 5
Top = 2400
Width = 2055
End
Begin VB.TextBox Text2
Height = 375
Left = 1800
TabIndex = 4
Top = 1680
Width = 2055
End
Begin VB.CommandButton Command4
Caption = "平均值"
Height = 375
Left = 360
TabIndex = 3
Top = 2400
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "最小值"
Height = 375
Left = 360
TabIndex = 2
Top = 1680
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "最大值"
Height = 375
Left = 360
TabIndex = 1
Top = 960
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "生成随机数"
Height = 495
Left = 1200
TabIndex = 0
Top = 120
Width = 1935
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim shu(1 To 10000) As Long
Private Sub Command1_Click()
Dim i As Integer
Dim shu As Long
Open App.Path + "\a.txt" For Output As #1
For i = 1 To 10000
Randomize
shu = Int(Rnd * (999999 - 100000 + 1) + 100000)
Print #1, shu
Next i
Close #1
End Sub
Private Sub Command2_Click()
Dim i, j As Integer
Dim temp As Long
Open App.Path + "\a.txt" For Input As #1
For i = 1 To 10000
Input #1, shu(i)
Next i
Close #1
For i = 1 To 9999
For j = i + 1 To 10000
If shu(i) > shu(j) Then
temp = shu(i)
shu(i) = shu(j)
shu(j) = temp
End If
Next j
Next i
Text1.Text = shu(10000)
End Sub
Private Sub Command3_Click()
Dim i, j As Integer
Dim temp As Long
Open App.Path + "\a.txt" For Input As #1
For i = 1 To 10000
Input #1, shu(i)
Next i
Close #1
For i = 1 To 9999
For j = i + 1 To 10000
If shu(i) > shu(j) Then
temp = shu(i)
shu(i) = shu(j)
shu(j) = temp
End If
Next j
Next i
Text2.Text = shu(1)
End Sub
Private Sub Command4_Click()
Dim i As Integer
Dim sum As Double
Open App.Path + "\a.txt" For Input As #1
For i = 1 To 10000
Input #1, shu(i)
Next i
Close #1
For i = 1 To 10000
sum = sum + shu(i)
Next i
Text3.Text = sum / 10000
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -