Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jan 19th, 2008, 6:36 PM   #1
kewlgeye
Programmer
 
Join Date: Jan 2008
Posts: 54
Rep Power: 1 kewlgeye is on a distinguished road
Question 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
kewlgeye is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC