结果未显示在Label中 [英] Results not displaying in Label
本文介绍了结果未显示在Label中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿大家我目前正在处理一个问题而且我在最后一部分遇到麻烦,我必须在所有分数中加上所有分数的总和而在特定类别中它似乎没有显示传递或失败时的值输入,我可以提出的任何提示或改进将不胜感激
我的问题的形象在这里:http://imgur.com/pw9XsyY
抱歉我的丑陋和糟糕的代码
谢谢!
Hey everyone i'm currently working a question and i'm having trouble on the final part where i have to add the sum of all scores and in the specific category it doesnt seems to be showing either pass or fail when the values are entered, any tips or improvements that i could make would be greatly appreciated
image of my question is here : http://imgur.com/pw9XsyY
sorry about my ugly and awful code
thanks!
Private Sub BtnPF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPF.Click
Dim Mynum1 As Integer
Dim Mynum2 As Integer
Dim Mynum3 As Integer
If Not IsNumeric(TxtboxS1.Text & TxtboxS2.Text & TxtboxS3.Text) Then
MessageBox.Show("Data not valid")
End If
If (IsNumeric(TxtboxS1.Text) = True) Then
Mynum1 = CInt(TxtboxS1.Text)
If (Mynum1 < 5 AndAlso Mynum2 < 5) Then
LblStatusBox.Text = "Fail"
If (IsNumeric(TxtboxS2.Text) = True) Then
Mynum2 = CInt(TxtboxS2.Text)
If (Mynum2 < 5 AndAlso Mynum3 < 5) Then
LblStatusBox.Text = "Fail"
If (IsNumeric(TxtboxS3.Text) = True) Then
Mynum3 = CInt(TxtboxS3.Text)
If (Mynum3 < 5 AndAlso Mynum3 < 5) Then
LblStatusBox.Text = "Fail"
End If
If (Mynum1 + Mynum2 + Mynum3 > 10) And TxtboxCat.Text = "A" Then
LblStatusBox.Text = "Pass"
If (Mynum1 + Mynum2 + Mynum3 > 15) And TxtboxCat.Text = "B" Then
LblStatusBox.Text = "Pass"
If (Mynum1 + Mynum2 + Mynum3 > 18) And TxtboxCat.Text = "C" Then
LblStatusBox.Text = "Pass"
Else
LblStatusBox.Text = "Fail"
End If
End If
End If
End If
End If
End If
End If
End If
推荐答案
你应该制作一个布尔变量hasPassed = False。
然后将所有TextBox.Text解析为整数。
按照你的逻辑,上面的所有内容都是多余的。使用布尔变量代替
You should make one boolean variable hasPassed=False.
Then as parse all TextBox.Text to Integers.
Following your logic, everything above here is superfluous. Use the boolean variable instead
If (Mynum1 + Mynum2 + Mynum3 > 10) And TxtboxCat.Text = "A" Then
hasPassed = true;
If (Mynum1 + Mynum2 + Mynum3 > 15) And TxtboxCat.Text = "B" Then
hasPassed = true;
If (Mynum1 + Mynum2 + Mynum3 > 18) And TxtboxCat.Text = "C" Then
hasPassed = true;
然后根据结果设置标签。
Then set the label based on the result.
这篇关于结果未显示在Label中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文