Here is a vb.net chatbot source code and screen shot found on Microsoft's website:
Citation:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/7290b676-6381-4b75-9335-4f599eb56132/need-help-creating-a-chat-bot-in-visual-basic-2010-or-visual-web-developer-express?forum=vbgeneralThis sample source code may have been posted anonymously, or is otherwise unclear as to who the author is. However, all credit goes to whoever that original author is. So, for reference in our discussion I will quote the vb.net source code listing:
Option Strict On
Public Class Form1
WithEvents txtChatInput As New TextBox
WithEvents btnSendInput As New Button
WithEvents txtOutput As New TextBox
Dim ChatItems As New List(Of ChatItem)
Dim CantAnswer As New List(Of String)
Dim CantRespond As New List(Of String)
Dim MonospacedFont As New Font("consolas", 12)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Width = 1000
Me.Height = 500
txtChatInput.Size = New Size(New Point(191, 20))
txtChatInput.Location = New Point(13, 29)
btnSendInput.Size = New Size(New Point(75, 20))
btnSendInput.Location = New Point(210, 29)
btnSendInput.Text = "Send"
txtOutput.Font = MonospacedFont
txtOutput.Left = 0
txtOutput.Multiline = True
txtOutput.WordWrap = False
txtOutput.ScrollBars = ScrollBars.Both
txtOutput.Top = txtChatInput.Top + txtChatInput.Height
txtOutput.Height = Me.ClientRectangle.Height - txtOutput.Top
txtOutput.Width = Me.ClientRectangle.Width
' txtOutput.Dock = DockStyle.Bottom
Me.Controls.Add(txtChatInput)
Me.Controls.Add(btnSendInput)
Me.Controls.Add(txtOutput)
Dim C1prompts As New List(Of String)
Dim C1Responses As New List(Of String)
C1prompts.Add("How are you doing today?")
C1prompts.Add("How are you doing?")
C1prompts.Add("How are you?")
C1prompts.Add("Are you doing well?")
C1Responses.Add("I'm doing great! Thanks for asking!")
C1Responses.Add("Not too shabby...")
C1Responses.Add("I can't compain!")
Dim ChatItem1 As New ChatItem(C1prompts, C1Responses)
ChatItems.Add(ChatItem1)
Dim C2prompts As New List(Of String)
Dim C2Responses As New List(Of String)
C2prompts.Add("Yes")
C2Responses.Add("ok good...")
C2Responses.Add("good to hear that...")
Dim ChatItem2 As New ChatItem(C2prompts, C2Responses)
ChatItems.Add(ChatItem2)
CantAnswer.Add("I refuse to answer that")
CantAnswer.Add("I don't even know why you would ask that...")
CantAnswer.Add("I don't know everything!")
CantAnswer.Add("What do I look like, an encyclopedia?")
CantAnswer.Add("Can we talk about something else?")
CantRespond.Add("Is that so?")
CantRespond.Add("I did not know that...")
CantRespond.Add("Why are you telling me this?")
CantRespond.Add("Absolutly amazing...")
CantRespond.Add("Does that even make sense?")
End Sub
Sub btnClick(ByVal sender As Object, ByVal e As EventArgs) Handles btnSendInput.Click
Randomize()
Dim Random As New Random
Dim Index As Integer
Dim Prompt As String = txtChatInput.Text
Dim PromptFound As Boolean = False
For Each ChatItem As ChatItem In ChatItems
If ChatItem.PromptFound(Prompt, False) Then
PromptFound = True
Select Case ChatItem.PromptCount < 3
Case True
Index = Random.Next(0, ChatItem.Responses.Count - 1)
txtOutput.Text = txtOutput.Text & vbCrLf & "You: " & Prompt & vbCrLf & "Computer: " & ChatItem.Responses(Index) & vbCrLf
ChatItem.PromptCount = ChatItem.PromptCount + 1
Case Else
Select Case ChatItem.PromptCount < 4
Case True
Select Case InStr(Prompt, "?") > 0
Case True
txtOutput.Text = txtOutput.Text & vbCrLf & "You: " & Prompt & vbCrLf & "Computer: " & "You have already asked me that " & ChatItem.PromptCount & " times... You know the answer..." & vbCrLf
Case Else
txtOutput.Text = txtOutput.Text & vbCrLf & "You: " & Prompt & vbCrLf & "Computer: " & "You have already said that " & ChatItem.PromptCount & " times... I am going to ignore you..." & vbCrLf
End Select
ChatItem.PromptCount = ChatItem.PromptCount + 1
Exit For
Case Else
txtOutput.Text = txtOutput.Text & vbCrLf & "You: " & Prompt & vbCrLf & "Computer: " & "dude say something new..." & vbCrLf
ChatItem.PromptCount = ChatItem.PromptCount + 1
Exit For
End Select
End Select
Else
ChatItem.PromptCount = 0
End If
Next
If Not PromptFound Then
If Not InStr(Prompt, "?") > 0 Then
Index = Random.Next(0, CantRespond.Count - 1)
txtOutput.Text = txtOutput.Text & vbCrLf & "You: " & Prompt & vbCrLf & "Computer: " & CantRespond(Index) & vbCrLf
Else
Index = Random.Next(0, CantAnswer.Count - 1)
txtOutput.Text = txtOutput.Text & vbCrLf & "You: " & Prompt & vbCrLf & "Computer: " & CantAnswer(Index) & vbCrLf
End If
End If
End Sub
End Class
Class ChatItem
Public Prompts As New List(Of String)
Public Responses As List(Of String)
Public PromptCount As Integer
Sub New(ByVal Prompts As List(Of String), ByVal Responses As List(Of String))
Me.Prompts = Prompts
Me.Responses = Responses
Me.PromptCount = 0
End Sub
Function PromptFound(ByVal Prompt As String, ByVal CaseSensitive As Boolean) As Boolean
Select Case CaseSensitive
Case True
If Not Prompts.IndexOf(Prompt) = -1 Then Return True
Return False
Case Else
Dim Exists As Boolean = False
For Each S As String In Prompts
If LCase(S) = LCase(Prompt) Then
Exists = True
End If
Next
Return Exists
End Select
End Function
End Class
Please visit the Microsoft.com link above for more information. The purpose of posting this source code is for discussion purposes and to help you find it on the Microsoft.com forum thread. If anyone can figure out the original author's name, please add it to this discussion.
EDIT:Looks like the author is...
Paul Ishak
Dirigo Systems Inc
_________________________________________________________________