📄 例[10-3].frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "例[10-3] 标准模块应用示例"
ClientHeight = 2910
ClientLeft = 60
ClientTop = 345
ClientWidth = 3540
LinkTopic = "Form1"
ScaleHeight = 2910
ScaleWidth = 3540
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton C1
Caption = "计算"
Height = 495
Left = 360
TabIndex = 3
Top = 1800
Width = 1215
End
Begin VB.TextBox T1
Height = 495
Left = 2040
TabIndex = 2
Top = 1800
Width = 1215
End
Begin VB.OptionButton Op2
Caption = "200-400之间素数"
Height = 495
Left = 360
TabIndex = 1
Top = 720
Width = 1935
End
Begin VB.OptionButton Op1
Caption = "100-200之间素数"
Height = 375
Left = 360
TabIndex = 0
Top = 240
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub C1_Click()
's用来存放素数和, a是范围的起始值,b是范围的终止值,i是循环控制变量
Dim s As Long, a As Integer, b As Integer, i As Integer
'根据单选按钮的选择来确定范围的起始值和终止值
If Op1.Value = True Then
a = 100
b = 200
ElseIf Op2.Value = True Then
a = 200
b = 400
End If
'求范围内素数和
For i = a To b
If isprime(i) = True Then
s = s + i
End If
Next i
'素数和显示在文本框中
T1.Text = s
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -