-
VS 2010 Huge issue ! Please Help !
-------------------------------------------------SOLVED-----------------------------------------------------------------------------------------------
Note : I am a bit of a novice at coding
So Im making A Chat Bot Application And Now I Want The Conversation To Be Able To Go In 2 Different Directions. But If I Have 2 Responses That Are The Same For Both Directions At The Same Time , "Yes" and "Yes" For Example, It Uses The Answer To The First Yes Every Time. If I Was Using The Second Side Of The Conversation , This Wouldn't Work , Any Ideas ?
Okay , Here Is Some Code
convo2 = Console.ReadLine()
If convo2 = "Good" Then
Console.WriteLine("That's Good, Do You Like Cake ?")
ElseIf convo2 = "Ok" Then
Console.WriteLine("Anything Bothering You At All ? Maybe A Little Cake Will Cheer You Up, Do You Like Cake ?")
ElseIf convo2 = "Sad" Then
Console.WriteLine(" Oh No ! Maybe Cake Will Cheer You Up , Do You Like Cake ?")
ElseIf convo2 = "Bad" Then
Console.WriteLine("Oh , Im Sorry To Hear That , Would Pie Cheer You Up ?") 'Line 2 States The 2nd Way The Conversation Could Expand'
Else
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("My Systems Can't Find A Response To That , Im Sorry")
End If
Console.ReadLine()
If convo3 = "Yes i love cake" Then
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine("Me Too !")
Console.WriteLine("Did You Know That Thanksgiving Is Coming Up Soon ?")
ElseIf convo3 = "Yes" Then
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine(" Me Too !")
Console.WriteLine("Did You Know That Thanksgiving Is Coming Up Soon ?")
ElseIf convo3 = "No" Then
Console.WriteLine("Oh , We'll I Do ")
Console.WriteLine("Did You Know That Thanksgiving Is Coming Up Soon ?")
ElseIf convo3 = "Yes" Then
Console.WriteLine("Im Glad , I Don't Have Any , But What I Do Have Is A Piece Of String , Would That Be Useful At All ?") 'Line 2'
Else
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("My Systems Can't Find A Response To That , Im Sorry")
End If
The two yes's in convo3 leads it to say the respons from the first path of the conversation instead of the second path. How do I fix this ?
-
Re: VS 2010 Huge issue ! Please Help !
First of all you should use Select Case statement. All these elseif look a bit messy. But apart from that I don't quiet understand what you're trying to say. Re-word your question.
-
Re: VS 2010 Huge issue ! Please Help !
So my program is a chat bot , I want the conversation to be able to go down two different paths like this Ex:
Hello
Me:Hello
Bot:How Are You
Me: Good
Bot: Do You Like Ice Cream ?
Me: Yes
Me Too !
Path 2 :
Hello
Me: Hello
How Are you?
Me: Bad
Oh No ! Do You Like Waffles
Me : Yes
That's Great !
---------------------
So How Do I Do This ? I Already Tried Select Case
How Can I Do This
-
Re: VS 2010 Huge issue ! Please Help !
Code:
Console.WriteLine("Hello how are you?")
Select Case Console.ReadLine.ToLower
Case "good", "great", "fine", "ok", "i'm good"
Console.WriteLine("That's great, do you like ice cream?")
If Console.ReadLine.ToLower = "yes" Then Console.WriteLine("Me too")
Case "bad", "not good", "****"
Console.WriteLine("Oh no! Do you like waffles?")
If Console.ReadLine.ToLower = "yes" Then Console.WriteLine("That's great")
Case Else
End Select
-
Re: VS 2010 Huge issue ! Please Help !
Where the if I wanted to add another
If conole.readline.tolower to that ? could I add one under it ?
-
Re: VS 2010 Huge issue ! Please Help !
ToLower should never be used for string comparison.
Use the String.ToUpperInvariant method instead of the String.ToLowerInvariant method when you normalize strings for .
-
Re: VS 2010 Huge issue ! Please Help !
What if I want
If Console.ReadLine.ToLower = "yes" Then Console.WriteLine("Me too")
To equal "no" , I tried adding an Elseif and another if below it , it didn't ork , any suggestions ?
-
Re: VS 2010 Huge issue ! Please Help !
yes, learn basic programming/!!!!!!!!!! it's else not elseif. Please take the time to read msdn
-
Re: VS 2010 Huge issue ! Please Help !
No Else defines , that if anything else other than what is specified is said then it will say this
Elseif is like another If
-
Re: VS 2010 Huge issue ! Please Help !
Don't ever teach me basic code.
Code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim messages = {"yes", "no", "other"}
For Each m In messages
Foo(m)
Next
End Sub
Private Sub Foo(value As String)
If value = "yes" Then
MsgBox("yes")
ElseIf value = "no" Then
MsgBox("no")
Else
MsgBox("other")
End If
End Sub
End Class
-
Re: VS 2010 Huge issue ! Please Help !
Yes I know , but that wont work for what Toph's code is
-
Re: VS 2010 Huge issue ! Please Help !
Quote:
Originally Posted by
Jasonpaul2001
No Else defines , that if anything else other than what is specified is said then it will say this
Elseif is like another If
You don't do ElseIf, you add another Case.
Else in a Case block is just if none of the other cases match.
-
Re: VS 2010 Huge issue ! Please Help !
Quote:
Originally Posted by
Jasonpaul2001
Where the if I wanted to add another
If conole.readline.tolower to that ? could I add one under it ?
Yes.
Code:
Select Case Console.ReadLine.ToLower
Case "good", "great", "fine", "ok", "i'm good"
Console.WriteLine("That's great, do you like ice cream?")
If Console.ReadLine.ToLower = "yes" Then Console.WriteLine("Me too")
Case "bad", "not good", "****"
Console.WriteLine("Oh no! Do you like waffles?")
Response = Console.ReadLine.ToUpper
If Response = "YES" Then
Console.WriteLine("That's great")
ElseIf Response = "NO" Then
Console.WriteLine("Too bad, I love them.")
Else
Console.WriteLine("I didn't understand that.")
End If
Case Else
'.....
Of course, if you want to continue with deeper and deeper nested logic for many questions, you probably don't want the Case statement anyway.
There are a number of similar programming examples from the 70's and 80's that did this sort of branching, with simulated learning as well. Try doing a search on Eliza and Guess the Animal programs.
An old example of Guess the Animal program.
-
Re: VS 2010 Huge issue ! Please Help !
Why Wont This Code Run After The "Console.WriteLine("Do You Think I Am A Good Robot ?")" About Halfway down
Module Module1
Sub Main()
Console.ForegroundColor = ConsoleColor.Yellow
Dim Response1 As String = Nothing
Dim Response2 As String = Nothing
Dim Response3 As String = Nothing
Dim Response4 As String = Nothing
Console.WriteLine("How Are You ? ?")
Select Case Console.ReadLine.ToLower
Case "good", "great", "fine", "ok", "i'm good"
Console.WriteLine("Thats Good ! , Do You Like Cats ?")
Response1 = Console.ReadLine.ToUpper
If Response1 = "YES" Then
Console.WriteLine("I Like Cats Too")
ElseIf Response1 = "NO" Then
Console.WriteLine("Ok")
Else
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("I Didn't Understand That.")
End If
Case "bad", "not good", "nipples"
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine("Oh no! Do you Like Dogs ?")
Response2 = Console.ReadLine.ToUpper
If Response2 = "YES" Then
Console.WriteLine("I Like Dogs Too")
ElseIf Response2 = "NO" Then
Console.WriteLine("Ok")
Else
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("I Didn't Understand That.")
Console.WriteLine("-----------------------------")
End If
Case Else
End Select
Console.ForegroundColor = ConsoleColor.Yellow
Console.WriteLine("Do You Think I Am A Good Robot ?")
Select Case Console.ReadLine.ToLower
Case "YES", "YEAH"
Console.WriteLine("Thank You , Im Glad You like me , Do You Like Thanksgiving ?")
Response3 = Console.ReadLine.ToUpper
If Response3 = "YES" Then
Console.WriteLine("Me Too , I Love The Turkey")
ElseIf Response3 = "NO" Then
Console.WriteLine("Well , Its Not For Everyone")
Else
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("I Didn't Understand That")
End If
Case "NO", "NAH", "NIPPLES"
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().ToUpper
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")
End If
End Select
Console.ReadLine()
End Sub
End Module
-
Re: VS 2010 Huge issue ! Please Help !
The first thing I noticed is you have two possible replies for a "Yes" answer. You are going to have to include the last question asked in your logic so it knows how to respond to the "Yes" answer.
-
Re: VS 2010 Huge issue ! Please Help !
-
Re: VS 2010 Huge issue ! Please Help !
like , I said im a newbie
-
Re: VS 2010 Huge issue ! Please Help !
Anyone have a suggestion ?
-
Re: VS 2010 Huge issue ! Please Help !
You are converting the entry to lowercase but trying to match upper case which will always fail
Code:
Console.WriteLine("Do You Think I Am A Good Robot ?")
Select Case Console.ReadLine.ToLower
Case "YES", "YEAH"
-
Re: VS 2010 Huge issue ! Please Help !
-
Re: VS 2010 Huge issue ! Please Help !
Quote:
Originally Posted by
Jasonpaul2001
Nope , Nothing
No idea what that is supposed to mean
-
Re: VS 2010 Huge issue ! Please Help !
-
Re: VS 2010 Huge issue ! Please Help !
What didn't work? I can't read your mind. Did you even understand the post?
-
Re: VS 2010 Huge issue ! Please Help !
I changed It to .ToLower and it still did the same thing
-
Re: VS 2010 Huge issue ! Please Help !
You changed what to lower?
What I showed was a direct quote of your code and that .ToLower is part of why it is not working.
Say the user types Yes your code makes that yes and then you check to see if it is YES which of course it can never be because you are forcing it to be all lower case.
Of course I am guessing still at what you mean by "it" because you did not say. I guess you think everyone knows what you mean when you use pro nouns but unless there is more info in your post to provide some context they are meaningless and makes for a waste of time.
Good luck
-
Re: VS 2010 Huge issue ! Please Help !
Omg , thank you thank you you fixed my problom