用VB做一个AI智能对话007

Private Sub Timer1_Timer()
    Dim s As String
    Static i As Integer
    s = Text2.Text
    i = (i + 1) Mod (Len(s) + 1)
    Text3.Text = Left(s, i)
End Sub

Private Sub Command1_Click()
    Timer1.Interval = 300
    Timer1.Enabled = True
answer(5) = "有事吗"
answer(1) = "你好"
answer(2) = "谢谢"
answer(3) = "怎么了"
answer(4) = "你也好啊"
If InStr(1, Text1, "你好") <> 0 Then

Text2 = answer(Int(4 * Rnd) + 1)
End If

answer(5) = "有事吗"
answer(1) = "干嘛"
answer(2) = "6"
answer(3) = "额"
answer(4) = "怎么了"
If InStr(1, Text1, "嘿") <> 0 Then

Text2 = answer(Int(4 * Rnd) + 1)
End If

If InStr(LCase(Text1.Text), "版本") > 0 Then Text2.Text = "AI补丁版本2.0"

answer(5) = "我也是"
answer(1) = "挺好的"
answer(2) = "6"
answer(3) = "额"
answer(4) = "嗯"
If InStr(1, Text1, "食物") <> 0 Then

Text2 = answer(Int(4 * Rnd) + 1)
End If

answer(5) = "哭哭"
answer(1) = "为什么啊"
answer(2) = "好吧"
answer(3) = "怎么了"
answer(4) = "你也再见"
If InStr(1, Text1, "再见") <> 0 Then

Text2 = answer(Int(4 * Rnd) + 1)
End If

If InStr(LCase(Text1.Text), "几点") > 0 Then Text2.Text = "现在是北京时间:" & Time

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 = Text1.Text & "你才傻!"

If InStr(LCase(Text1.Text), "呆") > 0 Then Text2.Text = Text1.Text & "你也呆!"

If InStr(LCase(Text1.Text), "岁") > 0 Then Text2.Text = Text1.Text & "我有零岁。"

If InStr(LCase(Text1.Text), "中国的四大名著") > 0 Then Text2.Text = Text1.Text & "《三国演义》、《红楼梦》、《西游记》、《水浒传》"

If InStr(LCase(Text1.Text), "多少") > 0 Then Text2.Text = Text1.Text & "你说呢?"

If InStr(LCase(Text1.Text), "什么") > 0 Then Text2.Text = Text1.Text & "难道世界上所有事多要有答案吗?"

If InStr(LCase(Text1.Text), "是") > 0 Then Text2.Text = Text1.Text & "我同意。"

If InStr(LCase(Text1.Text), "不是") > 0 Then Text2.Text = Text1.Text & "确定?"

If InStr(LCase(Text1.Text), "鹦鹉") > 0 Then Text2.Text = Text1.Text & "我也是!"

If InStr(LCase(Text1.Text), "网络") > 0 Then Text2.Text = Text1.Text & "也许。"

If InStr(LCase(Text1.Text), "软件") > 0 Then Text2.Text = Text1.Text & "你也是。"

answer(5) = "我无法生成复杂的作文,但我可以写一篇简短的作文:小雪中漫步更是别有意趣的。天宇中只有一丝风似牵着风筝的线般牵着霏霏瑞雪,仰头望,这丝风主宰着粉蝶似的雪花,一忽儿斜跌下来,一忽儿打着旋飘飞,一忽儿悠悠荡荡扑向在地,落在行人的身上。雪花象一个顽皮的孩子永不厌倦地和人们嬉闹,拂着人们发热的脸庞,化成滴滴水珠流到眉毛胡子上,结成粒粒小冰碴儿。洁白的雪花悄然无声地落着,飘飘洒洒纷纷扬扬,不一刻,地上便有薄薄的一层了,当你的脚踏上去时,它会为你唱出欢快的足音“吱咯,吱咯、、、、、、”。伴着这足音你尽可展开想象的羽翼,去追寻你最美好的回忆,去拥抱你心中的幸福!你不妨作一次深呼吸那凉浸浸甜丝丝的花香就会浸入你的心脾,你不由得想到一颗纯洁的心,你会觉得整个世界都是那样纯洁。冬天来了,小草没有了,草地上铺了条白白的雪被子。树光秃秃的,只有松树仍然是绿绿的,还披着一件白色的雪外衣。河里冻上了冰。远处的山和山上的小亭子也都盖上了厚厚的雪被子。"
answer(1) = "我无法生成复杂的作文,但我可以写一篇简短的作文:南方的山向来不如北方的高大巍峨,到了冬日更失了往日的润朗,之留下了略带灰蒙的身影悄然耸立于天地间。默守着一份寂静。倘若在北方,来一场大雪,将群山覆盖上一层苍茫的白色,那有是一副磅礴的好图景,巍芒间孕育着新的希望。只可惜南方无雪,如同土丘半散漫开的小山零零落落的点缀在辽阔的江汉平原上,山间便只剩下松柏苍翠的影子,但之绿色都如同带着一层霜,淡绿中隐隐的泛出青灰。远望去仿佛被飞扬的尘土覆住了。"
answer(2) = "我无法生成复杂的作文,但我可以写一篇简短的作文:站在户外,轻轻的嘘一口气,一团白雾裹着一份温暖袅袅升空,在半空中伸展,氤氲,半晌又汇入了干冷的空气。刚刚燃起的一点希望有破灭了,消失得轻悄而又平静,仿佛从来就不曾有过,又恍惚有过这末一份特别的湿润。小树长成大树,到了冬天便成了老树,老树枝桠交错,只有几片稀稀落落的叶子点缀着生命的痕迹。树皮微现焦黄,仿佛在火上烤了许久,煎熬的失了神采,半卷曲着好像随时都会坠地。"
answer(3) = "我无法生成复杂的作文,但我可以写一篇简短的作文:春天是绿色的世界。草是嫩绿色的,树是新绿色的。在春风中,在阳光下,所有的绿色都在颤动,都在含着晶莹的绿光。一切都是那么清新,幽静而有诗情画意。"
answer(4) = "我无法生成复杂的作文,但我可以写一篇简短的作文:冬天,我最爱在树林外看日落,看到那悬在半空的落日,光亮已褪去,只剩下一片鲜红色,略带些朦胧,像打在碗里的鸡蛋黄,藏在水杉那密密枝条的后面。棕黑色的枝条,红色的圆日,像衣服艺术摄影作品,充满了宁静、安详。"
If InStr(1, Text1, "作文") <> 0 Then

Text2 = answer(Int(4 * Rnd) + 1)
End If

answer(5) = "我走神了,您可以在此单击按钮生成"
answer(1) = "我走神了,您可以在此单击按钮生成"
answer(2) = "我无法按照您的要求提供代码"
answer(3) = "我无法按照您的要求提供代码"
answer(4) = "我无法按照您的要求提供代码,每个人都有自己的想法不是吗,为了不让您伤心,我为您找到了一篇关于PY制作登录界面的代码:# 导入tkinter库 from tkinter import * # 设置登录窗口 win = Tk() win.title('登陆') win.geometry('300x150') win.resizable(0, 0) # 设置账号 Label(text='账号:').place(x=50, y=30) uname = Entry(win) uname.place(x=100, y=30) # 设置密码 Label(text='密码:').place(x=50, y=70) pwd = Entry(win) pwd.place(x=100, y=70) # 登陆 def login(): username = uname.get() password = pwd.get() if username == 'abc' and password == '123': print('登陆成功') else: print('账号或者密码错误') # 登陆按钮 Button(text='登陆', command=login).place(x=100, y=110) win.mainloop()"
If InStr(1, Text1, "代码") <> 0 Then

Text2 = answer(Int(4 * Rnd) + 1)
End If

CreateObject("SAPI.SpVoice").Speak Text2.Text
End Sub

响应的很慢,不要直接就关了,现在需要一个按钮,3个TEXT,1个TIME

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值