📄 frm2d.frm
字号:
VERSION 5.00
Begin VB.Form frm2D
AutoRedraw = -1 'True
Caption = "Fig. 7.11: Two-Dimensional Arrays"
ClientHeight = 4935
ClientLeft = 2040
ClientTop = 765
ClientWidth = 5550
BeginProperty Font
Name = "Courier"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 4935
ScaleWidth = 5550
Begin VB.ListBox lstDisplay
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1080
Left = 1800
TabIndex = 5
Top = 1800
Width = 3495
End
Begin VB.ListBox lstValues
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1860
Left = 360
TabIndex = 4
Top = 1320
Width = 855
End
Begin VB.CommandButton cmdExit
BackColor = &H80000005&
Caption = "Exit"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 3480
TabIndex = 1
Top = 3960
Width = 1335
End
Begin VB.CommandButton cmdDisplay
BackColor = &H80000005&
Caption = "Display Array"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 360
TabIndex = 0
Top = 3960
Width = 2175
End
Begin VB.Label lblValues
Caption = "Values placed into array"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 975
Left = 360
TabIndex = 3
Top = 240
Width = 1215
End
Begin VB.Label lblDisplay
Caption = "Values stored inside the array:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 1800
TabIndex = 2
Top = 1080
Width = 3495
End
End
Attribute VB_Name = "frm2D"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 7.11
' Printing a two-dimensional array
Option Explicit
Option Base 1
' Declare two-dimensional array
Dim mArray(2, 3) As Integer
Private Sub Form_Load()
Dim x As Integer, y As Integer
Call Randomize
For x = LBound(mArray) To UBound(mArray)
For y = LBound(mArray, 2) To UBound(mArray, 2)
mArray(x, y) = 10 + Int(89 * Rnd())
Call lstValues.AddItem(mArray(x, y))
Next y
Next x
End Sub
Private Sub cmdDisplay_Click()
cmdDisplay.Enabled = False
Call PrintArray(mArray)
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub PrintArray(a() As Integer)
Dim row As Integer, col As Integer
Dim temp As String
temp = "Col 1 Col 2 Col 3"
Call lstDisplay.AddItem(Space$(6) & temp)
For row = LBound(mArray) To UBound(mArray)
temp = "Row " & row & " "
For col = LBound(mArray, 2) To UBound(mArray, 2)
temp = temp & Space$(3) & a(row, col) & " "
Next col
Call lstDisplay.AddItem(temp)
Next row
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -