例4.13.frm
来自「vb编程+从基础到实践光盘代码」· FRM 代码 · 共 83 行
FRM
83 行
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1440
TabIndex = 2
Top = 2160
Width = 1695
End
Begin VB.TextBox Txt2
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2760
TabIndex = 1
Top = 840
Width = 1215
End
Begin VB.TextBox Txt1
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 600
TabIndex = 0
Top = 840
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function mySum2(Operate As Integer, ParamArray var1()) As Integer
Dim int1 As Integer
Dim intSum As Integer
If Operate = 1 Then
intSum = 0 '计算连加,变量应初始化为0
For int1 = LBound(var1) To UBound(var1)
intSum = intSum + var1(int1)
Next
mySum2 = intSum '返回连加的计算结果
Else
intSum = 1 '计算连乘,变量应初始化为1
For int1 = LBound(var1) To UBound(var1)
intSum = intSum * var1(int1)
Next
mySum2 = intSum '返回连乘的计算结果
End If
End Function
Private Sub Command1_Click()
Dim int1 As Integer, int2 As Integer
int1 = mySum2(1, 1, 2, 3, 4, 5, 6)
int2 = mySum2(2, 1, 2, 3, 4, 5, 6)
Txt1.Text = int1
Txt2.Text = int2
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?