Option Explicit
Private WithEvents Command1 As CommandButton
Private Sub Form_Load()
Set Command1 = Controls.Add("vb.CommandButton", "Command1")
With Command1
.Visible = True
.Caption = "运行"
.Left = 100
.Top = 100
End With
With Me
.Width = 9000
.Height = 5000
.BorderStyle = 1
End With
End Sub
Private Sub Command1_Click()
Dim n1 As Byte, n2 As Byte
Dim A(5, 5) As Integer
Dim Max As Integer '记录最大值
Dim X As Byte, Y As Byte '记录最大值坐标
Cls
Me.CurrentX = 0
Me.CurrentY = 800
'自动生成25个区间在[100,999]的三位数
Randomize
For n1 = 1 To 5
For n2 = 1 To 5
A(n1, n2) = 900 * Rnd + 100
If A(n1, n2) > Max Then Max = A(n1, n2): X = n1: Y = n2
Print "A("; n1; ","; n2; ")="; A(n1, n2); Space(2);
Next n2
Print
Next n1
Print
Print "最大元数=" & Max, "所在坐标=" & "(" & X & "," & Y & ")"
End Sub