窗体Form1代码:
Private Sub Command1_Click()
ReDim Preserve Score(intCounter)
Score(intCounter) = 4
intCounter = intCounter + 1
End Sub
Private Sub Command2_Click()
ReDim Preserve Score(intCounter)
Score(intCounter) = 3
intCounter = intCounter + 1
End Sub
窗体Form2代码:
Private Sub Command1_Click()
ReDim Preserve Score(intCounter)
Score(intCounter) = 4
intCounter = intCounter + 1
End Sub
Private Sub Command2_Click()
ReDim Preserve Score(intCounter)
Score(intCounter) = 3
intCounter = intCounter + 1
End Sub
窗体Form3代码:
Private Sub Command1_Click()
Me.Cls
Dim Summation As Integer
For i = LBound(Score) To UBound(Score)
Summation = Summation + Score(i)
Next i
Print "Summation ="; Summation
End Sub
主窗体MDIForm1代码:
Private Sub LoadForm1_Click()
Load Form1
Form1.Show
End Sub
Private Sub LoadForm2_Click()
Load Form2
Form2.Show
End Sub
Private Sub LoadForm3_Click()
Load Form3
Form3.Show
End Sub
Private Sub MDIForm_Load()
intcount = 0
End Sub
标准模块Module1代码:
Public Score() As Integer, intCounter As Integer
运行效果:
主窗体MDIForm1菜单编辑:
设置2全局变量,用窗体一窗体二command赋值,窗体三中计算出相加结果。