|
-
Nov 24th, 2014, 04:35 PM
#1
Thread Starter
Lively Member
Case Statement Issue VS 2010 Plz Help
So Im Using The Case Statement In My Chat Bot Application And From My Code Below You Will See The Line "Do You Think I Am Nice" , Now , im trying to make it so that if you type in anything other than "yes" or "no" then it says "I Did Not Understand That". I tried using a case else statement and that did not work . any ideas ?
Code:
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine("Do You Think I Am Nice ?")
Select Case Console.ReadLine.ToLower
Case "yes", "no"
Console.WriteLine("Thank You , I'm Glad You Like me :) , Do You Like Thanksgiving ?")
Response3 = Console.ReadLine.ToUpper
If Response3 = "yes" Then
Console.WriteLine("Me Too , I Wish I Could Eat Turkey Though ....")
Console.WriteLine("Since I Am A Computer")
ElseIf Response3 = "no" Then
Console.WriteLine("Nice")
Else
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("I Didn't Understand That.")
Console.WriteLine("-----------------------------")
Console.ReadLine()
End
End If
Case "no", "nah"
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine(":( , Im Sorry , I'll Get You Flowers To Make Up For It , Do You Like Flowers ?")
Response4 = Console.ReadLine().ToLower
If Response4 = "yes" Then
Console.WriteLine("Okay I'll Talk To You Later , Im Off To Get Sunflowers , Bye")
ElseIf Response4 = "no" Then
Console.WriteLine("Okay , Ill Try To Be A Better Robot , Bye")
Else
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("I Didn't Understand That")
Console.WriteLine("-----------------------------")
Console.ReadLine()
End
End If
End Select
Console.ReadLine()
End Sub
End Module
Last edited by dday9; Nov 24th, 2014 at 04:36 PM.
Reason: Added code tags
-
Nov 24th, 2014, 04:37 PM
#2
Re: Case Statement Issue VS 2010 Plz Help
I've added code tags to your code. They help format the code properly and look like this:
[CODE][/CODE]
As for your question, just like If/Then statements, Select/Case statements contain an Else keyword:
Code:
Case Else
'Sorry I didn't understand that
-
Nov 24th, 2014, 04:39 PM
#3
Thread Starter
Lively Member
Re: Case Statement Issue VS 2010 Plz Help
I put that under Case and it gave me an error
-
Nov 24th, 2014, 04:48 PM
#4
Thread Starter
Lively Member
Re: Case Statement Issue VS 2010 Plz Help
it said
Error 1 'Case' cannot follow a 'Case Else' in the same 'Select' statement. C:\Users\jason_000\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Module1.vb 104 13 ConsoleApplication1
When I put a case else in
-
Nov 24th, 2014, 04:49 PM
#5
Re: Case Statement Issue VS 2010 Plz Help
Just like the If/Then statement it has to be the last case:
Code:
Select Case Console.ReadLine.ToLower
Case "yes", "no"
Case "no", "nah"
Case Else
End Select
-
Nov 24th, 2014, 04:51 PM
#6
Thread Starter
Lively Member
Re: Case Statement Issue VS 2010 Plz Help
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
|