![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Jan 2008
Posts: 53
Rep Power: 1
![]() |
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 |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jan 2008
Posts: 53
Rep Power: 1
![]() |
I figured it out. Thank you all who may have looked at this thread.
The solution was to place the summaryForm.ShowDialog at the bottom, or to the last 2 labels of the calculation. I also needed to use ElseIf statements. And modify the code a bit so that it wouldn't produce any message if the exact number was entered. Thanks again Multumesc Cpaciba Gracias |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
Re: What is Wrong with this If Statement? Please Help.
Next time use the code=vb tags like this:
vb Syntax (Toggle Plain Text)
|
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: What is Wrong with this If Statement? Please Help.
Just as a point of interest: part of the point of [code] tags is that they preserve indenting. If there's no indenting, please consider going back and putting some in - it makes the code a lot more readable.
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Apr 2008
Posts: 8
Rep Power: 0
![]() |
Re: What is Wrong with this If Statement? Please Help.
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 ----------------------------------------------------------------------------------------------------- I can see here that you basically have to if comparisons without an if statement. See you have one "If" after another. This is not acceptable in VB6. If cpaTextBox.Text > 9 Then should bbe elseIf cpaTextBox.Text > 9 Then
__________________
Opening you the door to success in the best freelance website: Rent a Coder |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Switch statement and strings | gamerfelipe | C | 5 | Apr 14th, 2007 11:20 AM |
| What's wrong with this code? | titaniumdecoy | Python | 25 | Jun 12th, 2006 12:46 PM |
| What is wrong with this code? | c0ldshadow | Visual Basic .NET | 5 | Dec 5th, 2005 5:37 PM |
| Trouble with a swith statement | cjaime | C | 10 | Nov 8th, 2005 11:09 AM |
| C++ vs. C# --- OOPS wrong thread sorry | Stash | Project Ideas | 0 | Jul 1st, 2005 11:28 AM |