📄 frmpassi.frm
字号:
VERSION 5.00
Begin VB.Form frmPassing
Caption = "Fig. 7.6: Passing Arrays "
ClientHeight = 4035
ClientLeft = 2040
ClientTop = 900
ClientWidth = 5310
BeginProperty Font
Name = "Courier"
Size = 10.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 4035
ScaleWidth = 5310
Begin VB.CommandButton cmdElement
BackColor = &H80000005&
Caption = "Element"
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 = 2160
TabIndex = 6
Top = 2040
Width = 1215
End
Begin VB.ListBox lstModified
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3060
Left = 3840
TabIndex = 3
Top = 840
Width = 1095
End
Begin VB.ListBox lstOriginal
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3060
Left = 480
TabIndex = 2
Top = 840
Width = 1095
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 = 615
Left = 2160
TabIndex = 1
Top = 3285
Width = 1215
End
Begin VB.CommandButton cmdDisplay
BackColor = &H80000005&
Caption = "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 = 2160
TabIndex = 0
Top = 840
Width = 1215
End
Begin VB.Label lblModified
Caption = "Modified Values:"
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 = 3840
TabIndex = 5
Top = 120
Width = 1335
End
Begin VB.Label lblOriginal
Caption = "Original Values:"
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 = 480
TabIndex = 4
Top = 120
Width = 1215
End
End
Attribute VB_Name = "frmPassing"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 7.6
' Passing an array and individual array
' elements to procedures
Option Explicit ' General declaration
' Declare array with indexes between -5 and 5
Dim mArray(-5 To 5) As Integer
Private Sub cmdDisplay_Click()
Dim x As Integer
' Initialize array and list boxes
Call Initialize
' Pass whole array call-by-reference
Call ModifyArray(mArray())
' Print modified values to list box
Call PrintModified
End Sub
Private Sub cmdElement_Click()
Dim x As Integer
' Initialize array
Call Initialize
For x = LBound(mArray) To UBound(mArray)
' Pass each element call-by-reference
Call ModifyElement(mArray(x))
Next x
Call PrintModified
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub Initialize()
Dim x As Integer
' Clear list boxes
lstOriginal.Clear
lstModified.Clear
' Place value into array
For x = LBound(mArray) To UBound(mArray)
mArray(x) = x
lstOriginal.AddItem mArray(x)
Next x
End Sub
Private Sub PrintModified()
Dim x As Integer
For x = LBound(mArray) To UBound(mArray)
lstModified.AddItem mArray(x)
Next x
End Sub
Private Sub ModifyArray(a() As Integer)
Dim x As Integer
For x = LBound(a) To UBound(a)
a(x) = a(x) * 2
Next x
End Sub
Private Sub ModifyElement(element As Integer)
element = element * 5
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -