📄 form0602.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "求最大公约数"
ClientHeight = 2940
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2940
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "关闭"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2520
TabIndex = 7
Top = 2160
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "计算"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 960
TabIndex = 6
Top = 2160
Width = 1095
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2520
Locked = -1 'True
TabIndex = 5
TabStop = 0 'False
Top = 1440
Width = 1095
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3360
TabIndex = 3
Top = 480
Width = 1095
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 1
Top = 480
Width = 1095
End
Begin VB.Label Label4
Caption = "最大公约数 ="
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 840
TabIndex = 4
Top = 1440
Width = 1575
End
Begin VB.Label Label2
Caption = "N ="
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2640
TabIndex = 2
Top = 480
Width = 735
End
Begin VB.Label Label1
Caption = "M ="
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 0
Top = 480
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Private Function Divisor(Optional ByVal x As Variant, Optional ByVal y As Variant) As Integer
'Private Function Divisor(x As Integer, y As Integer) As Integer
Private Function divisor(ParamArray n())
'通用函数求最大公约数
Dim r As Integer
'If IsMissing(x) Then x = 1
'If IsMissing(y) Then y = 1
If UBound(n) = 1 Then
x = n(0): y = n(1)
ElseIf UBound(n) = 0 Then
x = n(0): y = 1
End If
r = x Mod y
Do While r <> 0
x = y
y = r
r = x Mod y
Loop
divisor = y
End Function
Private Sub Command2_Click()
'单击结束按钮
End
End Sub
Private Sub Command1_Click()
'单击计算按钮
Dim Result As Integer
Dim m As Integer, n As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
If m <> 0 And n <> 0 Then
'Result = Divisor(m, n)
Result = divisor((m), (n))
Text3.Text = Result
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -