Chatbot help in storing multiple words as one variable to use instr() to see if any of it's variable

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello, my name is Foster, and I am a 15 year old high school senior. I have just recently, past 6 months or so, installed VB2010 express, and other than GML (Yoyogames.com Game Maker Language), I am new to the coding world. The only "major" project I have
completed using VB is a computer calculator that exactly mimics the capabilities of Windows 7s calculator. Yesterday, I began a Chatbot program for my girlfriend. Lol. I have used the instr() function to answer most of the questions or answers which are typed
into the textbox1. I find this extremely troublesome because when using the instr() function you cannot say instr(textbox1.text, "Hey" or "Hi") it must only be one. and then do an entire new line with the instr()) function for the next word. So what Im trying
to do here is use a variable, no, and store multiple words inside of it.... like no = "no nope na aint isnt never" and use instr() to see if any of those words are in the richtextbox and if they are, make the program say something in response to any of the
no variable words. Hmm... ill give u my entire source code, since its not very large at the moment, and if you see any errors other than that please notify me... Im just a beginner : but especially please help with the no variable problem. thanks. and
by the way, the code is very "cheesy" since its for my gf lol...
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Public <span style="color:Blue; Class Form1
<span style="color:Blue; Dim fos <span style="color:Blue; As <span style="color:Blue; String = <span style="color:#A31515; "Foster: "
<span style="color:Blue; Dim ash <span style="color:Blue; As <span style="color:Blue; String = <span style="color:#A31515; "Ashley: "
<span style="color:Blue; Dim rt <span style="color:Blue; As <span style="color:Blue; String
<span style="color:Blue; Dim stopit <span style="color:Blue; As <span style="color:Blue; Boolean
<span style="color:Blue; Dim userna = <span style="color:Blue; My.User.Name.ToString
<span style="color:Blue; Dim compna = <span style="color:Blue; My.Computer.Name.ToString
<span style="color:Blue; Dim username
<span style="color:Blue; Dim itsfalse <span style="color:Blue; As <span style="color:Blue; Boolean = <span style="color:Blue; True
<span style="color:Blue; Dim length <span style="color:Blue; As <span style="color:Blue; Integer = 0
<span style="color:Blue; Private <span style="color:Blue; Sub Button1_Click(sender <span style="color:Blue; As System.Object, e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles Button1.Click
<span style="color:Blue; If stopit = <span style="color:Blue; True <span style="color:Blue; Then
stopit = <span style="color:Blue; False
<span style="color:Blue; Exit <span style="color:Blue; Sub
<span style="color:Blue; End <span style="color:Blue; If
RichTextBox1.Clear()
RichTextBox1.ForeColor = Color.Blue
RichTextBox1.Text = ash & TextBox2.Text
TextBox2.Clear()
<span style="color:Blue; If RichTextBox1.Text = ash <span style="color:Blue; Then
RichTextBox1.ForeColor = Color.Red
RichTextBox1.Text = fos & <span style="color:#A31515; "Please at least type something! :"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; My.Computer.FileSystem.WriteAllText(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopchatbotlog.txt", RichTextBox1.Text & vbNewLine, <span style="color:Blue; True)
<span style="color:Blue; My.Computer.FileSystem.WriteAllText(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopneededforchatbot.txt", RichTextBox1.Text, <span style="color:Blue; False)
respond()
<span style="color:Blue; End <span style="color:Blue; Sub

<span style="color:Blue; Private <span style="color:Blue; Sub Timer1_Tick(sender <span style="color:Blue; As System.Object, e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles Timer1.Tick
RichTextBox1.Clear()
RichTextBox1.ForeColor = Color.Red
RichTextBox1.Text = fos & rt
rt = <span style="color:#A31515; ""
<span style="color:Blue; My.Computer.FileSystem.WriteAllText(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopchatbotlog.txt", RichTextBox1.Text & vbNewLine, <span style="color:Blue; True)
Timer1.<span style="color:Blue; Stop()
<span style="color:Blue; End <span style="color:Blue; Sub

<span style="color:Blue; Private <span style="color:Blue; Sub Form1_Load(sender <span style="color:Blue; As System.Object, e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.Load

RichTextBox1.Clear()
<span style="color:Blue; Dim this = Len(userna) - Len(compna)
username = Microsoft.VisualBasic.Right(<span style="color:Blue; My.User.Name.ToString, this)
stopit = <span style="color:Blue; True
RichTextBox1.ForeColor = Color.Red
RichTextBox1.Text = fos & <span style="color:#A31515; "Hello!"
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; Public <span style="color:Blue; Function respond()
<span style="color:Blue; If RichTextBox1.ForeColor = Color.Red <span style="color:Blue; Then
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; Dim no <span style="color:Blue; As <span style="color:Blue; String
no = <span style="color:#A31515; "no nope na ain isn never don"
Timer1.Start()
RichTextBox1.Text.ToLower()
<span style="color:Blue; If RichTextBox1.Text = fos & <span style="color:#A31515; "Bye." <span style="color:Blue; Then
Timer2.Enabled = <span style="color:Blue; True
Timer2.Start()
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; With RichTextBox1
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "love you") <span style="color:Blue; Then
rt = <span style="color:#A31515; "I love you too baby!! <3"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "favorite song") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Anything that reminds me of you :)"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "favorite movie") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Hmm... Twilight! :b"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "favorite book") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Twilight!!! Nah, Flash Burnout :]"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "your name? ") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Foster Tippins, duh. And you are, soon to be, Ashley Tippins!!"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "thank you") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Youre welcome!"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "thanks") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Youre welcome!"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "nothing") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Thats a lie! Theres always something"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "day go?") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Well, idk how the real me acted, but Amazing! As long as you were with me!"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "hey") <span style="color:Blue; Then
<span style="color:Blue; If itsfalse = <span style="color:Blue; True <span style="color:Blue; Then
rt = <span style="color:#A31515; "Whats up baby?"
itsfalse = <span style="color:Blue; False
length = 1
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "hi") <span style="color:Blue; Then
<span style="color:Blue; If itsfalse = <span style="color:Blue; True <span style="color:Blue; Then
rt = <span style="color:#A31515; "Whats up baby?"
itsfalse = <span style="color:Blue; False
length = 1
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "hello") <span style="color:Blue; Then
<span style="color:Blue; If itsfalse = <span style="color:Blue; True <span style="color:Blue; Then
rt = <span style="color:#A31515; "Whats up baby?"
itsfalse = <span style="color:Blue; False
length = 1
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If length = 1 <span style="color:Blue; Then
rt = <span style="color:#A31515; "So is this good or bad?"
length += 1
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If length = 2 <span style="color:Blue; Then
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "bad") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Awh, Im so sorry baby!! :( Is there anything I can do??"
length += 1
<span style="color:Blue; ElseIf InStr(.Text, <span style="color:#A31515; "good") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Yay! You so deserve it Ashley! Im happy for youu. I love you baby, always will <3"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If length = 3 <span style="color:Blue; Then
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "no") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Mkayys... Well just know that I will always be in love with you baby, no matter what my dumbass tells you... Im always here for ya :) So how long ago was our last argument?"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "yes") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Really? My capabilities are sorta limited ... but tell me and I mayy be able to help..."
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; ":)") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Im really glad you are happy Ashley, like no lie. Youre everything to me. Youre so freaking amazing! You have no idea.. :) So are we arguing now in real life or not?"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Im really glad you are happy Ashley, like no lie. Youre everything to me. Youre so freaking amazing! You have no idea.. :) So are we arguing now in real life or not?"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; My.Computer.FileSystem.WriteAllText(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopchatbotlogfoster.txt", rt, <span style="color:Blue; False)
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If length = 4 <span style="color:Blue; Then
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "day") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Wow ... Im sorry. Its probably my fault. Everything is. I screw everything up baby ... : So was it really my fault?"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "week") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Well that aint too terrible... still hate myself for ever agruging with such a ****ing amazing girl like youu .. : So was it my fault as always baby?"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "month") <span style="color:Blue; Then
rt = <span style="color:#A31515; "WOW! That isnt too badd :) Still hate that I ever get into fights with such an amazing girl like youu thoo. So why you talking to me today?"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; Dim a = <span style="color:Blue; My.Computer.FileSystem.ReadAllText(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopchatbotlogfoster.txt")
<span style="color:Blue; If a = <span style="color:#A31515; "Really? My capabilities are sorta limited ... but tell me and I mayy be able to help..." <span style="color:Blue; Then
a = 1
<span style="color:Blue; Else
a = 2
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If a = 1 <span style="color:Blue; Then
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "yes") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Haha Ashley, I really cant do much at all. I can say this tho, you are the absolute greatest girl/girlfriend in the entire world!! Im so freaking lucky to have youu, ya have no idea...! So why you talking to me today?"
length += 1
<span style="color:Blue; ElseIf InStr(.Text, <span style="color:#A31515; "no") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Haha, well I didnt really think I could anyways lol. But I can say this much, you are the absolute greatest girl/girlfriend in the entire world!! Im so freaking lucky to have youu, ya habe no idea...! So why you talking to me today?"
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; ElseIf a = 2 <span style="color:Blue; Then
<span style="color:Blue; If InStr(.Text, <span style="color:#A31515; "no") <span style="color:Blue; Then
rt = <span style="color:#A31515; "Good!! We shouldnt be. I dont know how Im so stupid to argue with the most beautiful girl everrrrr anyways :( So this is all of the Chatbot I have done at the moment conversation wise.... but you can ask me questions and Ill still answer them :) Also, on your desktop there will be an icon named chatbotlog.txt that has this whole conversation so you can read it at anny time! So ask away!"
length += 999
<span style="color:Blue; ElseIf InStr(.Text, <span style="color:#A31515; "yes") <span style="color:Blue; Then
rt = <span style="color:#A31515; "****!! Gosh Im sucha faggot : I freaking argue over the smallest things with the most amazing girl everrr! IDK why :( Im so sorry... just give me a bit and Ill come around and Ill calm down and make it all better baby... :( I hate my self... tell me all of what happened please."
length += 1
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; Exit <span style="color:Blue; Function
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; If length = 5 <span style="color:Blue; Then
rt = <span style="color:#A31515; ":( Im so sorry and dumb Ashley... I love youuu! Just remember that... But I have reached the end of my capabilities as a conversation Chabot, but you can still ask questions and some I may answer. Also, on your desktop there will be an icon named chatbotlog.txt that has this whole conversation so you can read it at anny time! So ask away:) "
length += 999
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; End <span style="color:Blue; With
<span style="color:Blue; If rt = <span style="color:#A31515; "" <span style="color:Blue; Then
rt = <span style="color:#A31515; "Hmm... no answers were found to that remark. You sure you spelled everything correctly? Maybe try again?"
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Blue; My.Computer.FileSystem.WriteAllText(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopchatbotlogfoster.txt", rt, <span style="color:Blue; False)
<span style="color:Blue; End <span style="color:Blue; Function

<span style="color:Blue; Private <span style="color:Blue; Sub Timer2_Tick(sender <span style="color:Blue; As System.Object, e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles Timer2.Tick

<span style="color:Blue; Me.Close()
<span style="color:Blue; End <span style="color:Blue; Sub

<span style="color:Blue; Private <span style="color:Blue; Sub TextBox2_Enter(sender <span style="color:Blue; As System.Object, e <span style="color:Blue; As System.EventArgs) <span style="color:Blue; Handles TextBox2.Enter
Button1.PerformClick()
<span style="color:Blue; End <span style="color:Blue; Sub

<span style="color:Blue; Private <span style="color:Blue; Sub Form1_FormClosing(sender <span style="color:Blue; As System.Object, e <span style="color:Blue; As System.Windows.Forms.FormClosingEventArgs) <span style="color:Blue; Handles <span style="color:Blue; MyBase.FormClosing
<span style="color:Blue; My.Computer.FileSystem.DeleteFile(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopneededforchatbot.txt")
<span style="color:Blue; My.Computer.FileSystem.DeleteFile(<span style="color:#A31515; "C:Users" & username & <span style="color:#A31515; "Desktopchatbotlogfoster.txt")
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; End <span style="color:Blue; Class

[/code]
<br/>

View the full article
 
Back
Top