-
September 12th, 2019, 09:29 PM
#1
[RESOLVED] Help with Select / Case Statement in Visual Studio 2012 Express
I have written a simple project that need to evaluate a score (variable = TotalMatches).
I have Case statements that are not being evaluated as they should. Here is my code:
Code:
Private Sub Rate_Num_Matches()
Dim myprompt As String = Nothing
Select Case True
Case My.Settings.MatchNumbers
Dim ExpectedMatches As Integer = (26 * My.Settings.NumRounds)
Select Case TotalMatches
Case ExpectedMatches
myprompt = "You did an EXCELLENT JOB of matching all " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 1) To (ExpectedMatches - 9)
myprompt = "You did an FANTASTIC JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 10) To (ExpectedMatches - 14)
myprompt = "You did an GREAT JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 15) To (ExpectedMatches - 19)
myprompt = "You did an GOOD JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 20) To (ExpectedMatches - 25)
myprompt = "You did an FINE JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case 0
myprompt = "SORRY you didn't match any of the sets of cards!"
End Select
Case My.Settings.MatchSuits
Dim ExpectedMatches As Integer = (24 * My.Settings.NumRounds)
Select Case TotalMatches
Case ExpectedMatches
myprompt = "You did an EXCELLENT JOB of matching all " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 1) To (ExpectedMatches - 9)
myprompt = "You did an FANTASTIC JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 10) To (ExpectedMatches - 14)
myprompt = "You did an GREAT JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 15) To (ExpectedMatches - 19)
myprompt = "You did an GOOD JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case (ExpectedMatches - 20) To (ExpectedMatches - 23)
myprompt = "You did an FINE JOB of matching " & Trim(Str(ExpectedMatches)) & " sets of cards!"
Case 0
myprompt = "SORRY you didn't match any of the sets of cards!"
End Select
End Select
Label7.Text = myprompt
Label7.Show()
GroupBox1.Refresh()
clr7 = "SHOW"
My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Exclamation)
End Sub
As an example, I played 1 game MatchingNumbers with 1 round and got a score of 5 (ie: TotalMatches = 5). It should have evaluated to the Case statement in RED. Label7 remained blank because the variable: myprompt was NULL. What is wrong?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|