从现在开始,我们要用VB做一款聊天机器人
材料:VB6.0
准备:拉出2个text控件,一个command控件
代码可以这样写:(仅供参考)
Private Sub Command1_Click()
If InStr(LCase(Text1.Text), "你好") > 0 Then Text2.Text = "你也好"
End Sub
毕竟还是太枯燥了,我们可以增加一些内容,那么这串代码就变成了这样:
Private Sub Command1_Click()
If InStr(LCase(Text1.Text), "你好") > 0 Then Text2.Text = "你也好"
If InStr(LCase(Text1.Text), "厉害啊") > 0 Then Text2.Text = "谢谢夸奖"
If InStr(LCase(Text1.Text), "谢谢") > 0 Then Text2.Text = "不用谢"
End Sub
这样的话就好了很多,如果有需要的话,还可以自己进行美化