What is Wrong with this If Statement? Please Help.
Hello,
You will notice that some of the code wrapped, so disregard this please.
When I run the program I have one message in a group box on a summary form and another message in a group box below that. When on the input page I input information for the second textbox and click the calculate button, it keeps showing me only the first 2 messages "the one above and below" however, when I click the button again, or close it refreshes the information with the other 2 messages properly.
I need this to display the messages I have below the first time I press the calculate button, and I can't figure out why, I think it must have something to do with my if statements, because the form displays correctly all the information, however, I have to click the calculate button twice, or select the close button.
What do you think?
Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
' Calculate the totals to see if staffing is needed in certain areas or not.
Dim messageString As String
Dim messageString2 As String
Dim messageString3 As String
Dim messageString4 As String
Dim messageString5 As String
Dim messageString6 As String
Dim messageString7 As String
Dim messageString8 As String
Dim countaDecimal As Decimal = 9 - cpaTextBox.Text
Dim cpaMaxDecimal As Decimal = cpaTextBox.Text - 9
Dim countbDecimal As Decimal = 13 - cpbTextBox.Text
Dim cpbMaxDecimal As Decimal = cpbTextBox.Text - 13
' Team A Calculations.
With Me
If cpaTextBox.Text < 9 Then
messageString = "Checkpoint A is understaffed by " & countaDecimal & " player(s)."
.cparesponse = messageString
messageString2 = "Send " & countaDecimal & " player(s) to CheckPoint A."
.cparecommendation = messageString2
summaryForm.ShowDialog()
If cpaTextBox.Text > 9 Then
messageString3 = ""
.cparesponse = messageString3
messageString4 = "You can send " & cpaMaxDecimal & " player(s) from Team A to other locations if needed."
.cparecommendation = messageString4
Else
End If
' Team B Calculations
If cpbTextBox.Text < 13 Then
messageString5 = "Team B is understaffed by " & countbDecimal & " player(s)."
.cpbresponse = messageString5
messageString6 = "Send " & countbDecimal & " player(s) to Team B."
.cpbrecommendation = messageString6
summaryForm.ShowDialog()
If cpbTextBox.Text > 13 Then
messageString7 = ""
.cpbresponse = messageString7
messageString8 = "You can send " & cpbMaxDecimal & " player(s) from Team B to other locations if needed."
.cpbrecommendation = messageString8
Else
End If
End If
End If
End With
End Sub
|