麻煩會VB的高手們
幫我修改一個程式
可以輸入無限多次數值資料
直到輸入非數值資料以後停止
並列印出輸入幾次數值資料
最後 列印剛剛所輸入之數值資料中
最大的值&最小的值
下面是我自己打的
但是一直不成功
不知道為什麼
希望有人可以幫我修改
3Q
Private Sub Form_Activate()
Dim a As String
Dim x As Integer
Dim y As Integer
Dim z As Integer
y = 32767
z = -32768
L1: a = InputBox("輸入數值")
If IsNumeric(a) Then
x = x 1
y = Val(a)
z = Val(a)
If a > y And z > y Then
a = y
ElseIf z > a And z > y Then
a = z
End If
GoTo L1
End If
Print "共輸入"; x; "次數值"
Print y; "為最小值"
Print z; "為最大值"
End Sub
2005-12-28 17:24:34 · 1 個解答 · 發問者 Anonymous in 電腦與網際網路 ➔ 程式設計
Dim x As Integer, y As Integer, z As Integer
Dim Max As String, Min As String, a As String
y = 32767: z = -32768
L1: a = InputBox("輸入數值")
If IsNumeric(a) Then
If Val(a) < z Or Val(a) > y Then GoTo L1
If Max = "" Then Max = Int(a): If Min = "" Then Min = Max
If Int(Max) > Int(a) Then Max = Int(a)
If Int(Min) < Int(a) Then Min = Int(a)
x = x + 1
GoTo L1
End If
Print "共輸入"; x; "次數值"
Print Max; "為最小值"
Print Min; "為最大值"
2005-12-28 17:44:46 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋