4.4.frm
来自「VB6.0应用例题」· FRM 代码 · 共 33 行
FRM
33 行
VERSION 5.00
Begin VB.Form Form1
Caption = "找最大值及其位置"
ClientHeight = 2280
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2280
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Click()
Const Length = 5 '定义常量Length作为数组最大下标
Dim Test%(Length), I%, Max%, L%
For I = 1 To Length '通过键盘给数组赋值
Test(I) = InputBox("输入第" & I & "个数据")
Next I
Max = Test(1): L = 1 '设数组第一个元素为最大值
For I = 2 To Length
If Max < Test(I) Then '找到新的最大值,记录其值和位置
Max = Test(I)
L = I
End If
Next I
MsgBox "最大值Max=" & Max & ",其位置是" & L
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?