會VB的請進來一下



贊助商連結


lin1141
2002-11-27, 11:18 PM
請大大幫我看以下程式錯在那裡,並告訴我要如何訂正,謝謝!
Private Sub Command1_Click()
A = Val(InputBox("請輸入A"))
B = Val(InputBox("請輸入B"))
B = Val(InputBox("請輸入C"))
If A > B And A > C Then
MsgBox "A最大"
If B > C And B > A Then
MsgBox "B最大"
Else
MsgBox "C最大"
End If


End Sub

贊助商連結


ranger
2002-11-27, 11:30 PM
Private Sub Command1_Click()
A = Val(InputBox("請輸入A"))
B = Val(InputBox("請輸入B"))
C = Val(InputBox("請輸入C"))
If A > B And A > C Then
MsgBox "A最大"
ElseIf B > C And B > A Then
MsgBox "B最大"
Else
MsgBox "C最大"
End If

End Sub

VicLin
2002-11-27, 11:30 PM
Private Sub Command1_Click()
Dim A As Integer
Dim B As Integer
Dim C As Integer
A = Val(InputBox("½Ð¿é¤JA"))
B = Val(InputBox("½Ð¿é¤JB"))
C = Val(InputBox("½Ð¿é¤JC"))
If A > B And A > C Then
MsgBox "A³Ì¤j"
ElseIf B > C And B > A Then
MsgBox "B³Ì¤j"
Else
MsgBox "C³Ì¤j"
End If
End Sub

我幫你改好了

你知道嗎?
這個程式跟我有生以來第一個程式一樣~都是在比大小
推薦你一個學VB的好地方
http://www.infoserv.com.tw/vb/
當初我是在這學會VB的

logic
2002-11-28, 12:36 AM
提供一個之前我老師講過的解法
我覺得蠻不錯用的

a = Val(InputBox("請輸入A"))
b = Val(InputBox("請輸入B"))
c = Val(InputBox("請輸入C"))
Min = 32768
If a < Min Then
Min = a
ElseIf b < Min Then
Min = b
ElseIf c < Min Then
Min = c
End If
MsgBox Min

這樣不管是比較幾個數都可以用哦
多寫幾個 elseif 就好了