VERSION 5.00 Begin VB.Form frmMaximum Caption = "Maximum" ClientHeight = 7575 ClientLeft = 60 ClientTop = 345 ClientWidth = 5835 BeginProperty Font Name = "MS Sans Serif" Size = 18 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty LinkTopic = "Form1" ScaleHeight = 7575 ScaleWidth = 5835 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdRun Caption = "Run" Height = 735 Left = 120 TabIndex = 0 Top = 240 Width = 1455 End End Attribute VB_Name = "frmMaximum" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ' Maximum - Demonstrate arrays, for..next loop, print on form ' ' 9-May-2000 J. Jacky Begun Option Explicit ' require type declarations Private Sub cmdRun_Click() Dim list(10) As Integer ' a list of 10 numbers Dim i As Integer ' index, identifies one element of list Dim max As Integer ' the largest number in the list ' Initialize form printing frmMaximum.Cls ' clear screen of printing from last time frmMaximum.CurrentY = 220 ' looks good with 18 pt text For i = 1 To 3 frmMaximum.Print ' leave some space Next i ' Fill the list with random numbers and print max = 0 ' initialize maximum For i = 1 To 10 list(i) = Int(100 * Rnd()) If list(i) > max Then max = list(i) frmMaximum.Print " i "; i; " list(i) "; list(i) Next i ' Report the maximum frmMaximum.Print ' leave some space frmMaximum.Print " The largest number is "; max End Sub Private Sub Form_Load() Randomize ' otherwise rnd always returns same sequence End Sub