vb程序题。求解!

2025-06-23 21:09:48
推荐回答(4个)
回答1:

你在通用窗口定义A,B变量就行了,或者定义全局变量
Public 声明的就是全局的..

回答2:

Option Explicit

Dim d(10) As Double, s As Double, i As Integer
Private Sub Command1_Click()
For i = 0 To 1 Step 1
d(i) = Val(InputBox("输入第" & i + 1 & "个数:"))
Next i
End Sub
Private Sub Command2_Click()
'Call Command1_Click
s = 0
For i = 0 To 1 Step 1
s = s + d(i)
Next i
MsgBox "两数的和是:" & s
End Sub

回答3:

Dim a, b
Private Sub Command1_Click()
a = Val(InputBox("input A"))
b = Val(InputBox("input B"))
End Sub

Private Sub Command2_Click()
MsgBox a + b
End Sub

回答4:

Option Explicit
Dim A As Single, B As Single
Private Sub Command1_Click()
A = Val(InputBox("A", ""))
B = Val(InputBox("B", ""))
End Sub

Private Sub Command2_Click()
Dim C As Single, D As String
C = A + B
D = C
MsgBox (D)
End Sub