您好,我在vb.net中遇到大於小於函數的問題。它的正確數字完美地工作,但不會與負數工作。這是我的代碼,我希望這可以幫助。大於,小於負數
Dim A, B, input As Integer
A = (-38)
B = (-173)
txtD.Text = CStr(CInt(txtD.Text))
input = CInt(txtD.Text)
If input <= 32 < CInt(A) Then
txtR.Text = "Water will freeze and Oxygen will boil at this Temperature"
ElseIf input <= CInt(A) > CInt(B) Then
txtR.Text = "Water and Mercury will Freeze and Oxygen will boil at this temperature"
End If
你還沒有給你的輸入,預期與實際結果的一個例子。我個人建議一次只表達一個條件並使用'AndAlso'(或其他)來組合它們 - 對我來說(作爲一個簡單的C#開發者)我不清楚CInt(B)'是如何輸入的評估。 –
(也不清楚爲什麼你使用'CInt(A)'和'CInt(B)'時它們已經是整數。) –
請注意,如果你有'Option Strict',你會收到錯誤消息已經由於代碼問題。我強烈建議你開始使用'Option Strict' ... –