条件得到满足,但它没有运行代码

时间:2014-03-17 10:29:25

标签: vb.net

If (need_1a.Text <= ava_4a.Text) And (need_1b.Text <= ava_4b.Text) And (need_1c.Text <= ava_4c.Text) Then
            ava_5a.Text = Convert.ToInt32(ava_4a.Text) - Convert.ToInt32(need_1a.Text) + Convert.ToInt32(max_1a.Text)
            ava_5b.Text = Convert.ToInt32(ava_4b.Text) - Convert.ToInt32(need_1b.Text) + Convert.ToInt32(max_1b.Text)
            ava_5c.Text = Convert.ToInt32(ava_4c.Text) - Convert.ToInt32(need_1c.Text) + Convert.ToInt32(max_1c.Text)
            need1 = 4
        ElseIf (need_5a.Text <= ava_4a.Text) And (need_5b.Text <= ava_4b.Text) And (need_5c.Text <= ava_4c.Text) Then
            ava_5a.Text = Convert.ToInt32(ava_4a.Text) - Convert.ToInt32(need_5a.Text) + Convert.ToInt32(max_5a.Text)
            ava_5b.Text = Convert.ToInt32(ava_4b.Text) - Convert.ToInt32(need_5b.Text) + Convert.ToInt32(max_5b.Text)
            ava_5c.Text = Convert.ToInt32(ava_4c.Text) - Convert.ToInt32(need_5c.Text) + Convert.ToInt32(max_5c.Text)
            need5 = 4
        End If

我有这个代码,满足第一个条件,但它不运行代码。

deadlock app

1 个答案:

答案 0 :(得分:0)

使用Val ()

没有val(),这是一个字符串比较。

    If (Val(need_1a.Text) <= Val(ava_4a.Text)) And (Val(need_1b.Text) <= Val(ava_4b.Tex)t)
    And (Val(need_1c.Text) <= Valava_4c.Text)) Then

       ava_5a.Text = Convert.ToInt32(ava_4a.Text) - Convert.ToInt32(need_1a.Text) + 
       Convert.ToInt32(max_1a.Text)
       ava_5b.Text = Convert.ToInt32(ava_4b.Text) - Convert.ToInt32(need_1b.Text) +
       Convert.ToInt32(max_1b.Text)
       ava_5c.Text = Convert.ToInt32(ava_4c.Text) - Convert.ToInt32(need_1c.Text) + 
       Convert.ToInt32(max_1c.Text)
       need1 = 4

   ElseIf (Val(need_5a.Text) <= Val(ava_4a.Text)) And (Val(need_5b.Text) <= 
   Val(ava_4b.Text)) And (Val(need_5c.Text) <= Val(ava_4c.Text)) Then

       ava_5a.Text = Convert.ToInt32(ava_4a.Text) - Convert.ToInt32(need_5a.Text) + 
       Convert.ToInt32(max_5a.Text)
       ava_5b.Text = Convert.ToInt32(ava_4b.Text) - Convert.ToInt32(need_5b.Text) + 
       Convert.ToInt32(max_5b.Text)
       ava_5c.Text = Convert.ToInt32(ava_4c.Text) - Convert.ToInt32(need_5c.Text) + 
       Convert.ToInt32(max_5c.Text)
        need5 = 4

   End If