2014-03-04 82 views
-2

我的狀況並不好,那是什麼問題?任何人都可以幫我嗎?爲什麼我的情況沒有按預期工作?

Public Class Form5 

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged 
     Dim a As Integer 
     If TextBox1.Text = "" Then 
      TextBox2.Text = "" 
     End If 

     a = Val(TextBox1.Text) 
     If TextBox1.Text = "" Then 
      TextBox2.Text = "" 
     ElseIf (a < 4.9) Then 
      TextBox2.Text = ("Little or No Damage") 
     ElseIf (a <= 5 AndAlso a >= 5.5) Then 
      TextBox2.Text = ("Some Damage") 
     ElseIf (a <= 5.6 And a >= 6.5) Then 
      TextBox2.Text = ("Serious Damage") 
     ElseIf (a <= 6.6 And a >= 7.5) Then 
      TextBox2.Text = ("Disaster") 
     ElseIf (a > 7.5) Then 
      TextBox2.Text = ("Catasthrope") 
     End If 

    End Sub 
End Class 
+7

如何'了'小於或等於5 *和*大於或等於5.5在同一時間? (例如) –

+0

「lang po」?這究竟是什麼意思? –

+0

看來你只是混了'<=' and '> =' – sloth

回答

3

你只混了<=>=

但它會更易讀且不易出錯,如果你會使用Select代替,例如:

Select Case a 
    Case Is < 4.9 
     TextBox2.Text= "Little or No Damage" 
    Case 5 To 5.5 
     TextBox2.Text= "Some Damage" 
    Case 5.6 To 6.5 
     TextBox2.Text= "Serious Damage" 
    Case 6.6 To 7.5 
     TextBox2.Text= "Disaster" 
    Case Is > 7.5 
     TextBox2.Text= "Catasthrope" 
End Select 
+0

tnx我明白了。 Godbless – user3379407

+0

@ user3379407瞭解SO規則,您應該將此答案標記爲已接受。一個'Thankyou'在這裏不受歡迎。 – ElektroStudios

相關問題