-
Nov 23rd, 2014, 11:41 AM
#1
Thread Starter
Lively Member
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 ?
Last edited by Jasonpaul2001; Nov 23rd, 2014 at 08:21 PM.
Reason: (SOLVED)
-
Nov 23rd, 2014, 12:14 PM
#2
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.
-
Nov 23rd, 2014, 12:37 PM
#3
Thread Starter
Lively Member
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
-
Nov 23rd, 2014, 01:15 PM
#4
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
-
Nov 23rd, 2014, 01:50 PM
#5
Thread Starter
Lively Member
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 ?
-
Nov 23rd, 2014, 01:54 PM
#6
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 .
-
Nov 23rd, 2014, 01:59 PM
#7
Thread Starter
Lively Member
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 ?
-
Nov 23rd, 2014, 02:02 PM
#8
Re: VS 2010 Huge issue ! Please Help !
yes, learn basic programming/!!!!!!!!!! it's else not elseif. Please take the time to read msdn
-
Nov 23rd, 2014, 02:04 PM
#9
Thread Starter
Lively Member
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
-
Nov 23rd, 2014, 02:09 PM
#10
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
-
Nov 23rd, 2014, 02:11 PM
#11
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
Yes I know , but that wont work for what Toph's code is
-
Nov 23rd, 2014, 02:18 PM
#12
Re: VS 2010 Huge issue ! Please Help !
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.
-
Nov 23rd, 2014, 02:30 PM
#13
Re: VS 2010 Huge issue ! Please Help !
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.
Last edited by passel; Nov 23rd, 2014 at 02:37 PM.
-
Nov 23rd, 2014, 04:37 PM
#14
Thread Starter
Lively Member
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
-
Nov 23rd, 2014, 04:42 PM
#15
New Member
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.
-
Nov 23rd, 2014, 04:44 PM
#16
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
-
Nov 23rd, 2014, 04:44 PM
#17
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
like , I said im a newbie
-
Nov 23rd, 2014, 04:52 PM
#18
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
Anyone have a suggestion ?
-
Nov 23rd, 2014, 07:04 PM
#19
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"
-
Nov 23rd, 2014, 07:23 PM
#20
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
-
Nov 23rd, 2014, 07:55 PM
#21
Re: VS 2010 Huge issue ! Please Help !
Originally Posted by Jasonpaul2001
Nope , Nothing
No idea what that is supposed to mean
-
Nov 23rd, 2014, 08:00 PM
#22
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
-
Nov 23rd, 2014, 08:03 PM
#23
Re: VS 2010 Huge issue ! Please Help !
What didn't work? I can't read your mind. Did you even understand the post?
-
Nov 23rd, 2014, 08:04 PM
#24
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
I changed It to .ToLower and it still did the same thing
-
Nov 23rd, 2014, 08:10 PM
#25
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
-
Nov 23rd, 2014, 08:12 PM
#26
Thread Starter
Lively Member
Re: VS 2010 Huge issue ! Please Help !
Omg , thank you thank you you fixed my problom
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
|