以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]获取openQQ登陆者表达问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=76954)

--  作者:xianzheng
--  发布时间:2015/11/8 21:42:00
--  [求助]获取openQQ登陆者表达问题

 [求助]下面代码获取openQQ“登陆者”表达有问题问题,请老师帮修改

Dim re As String = e.Form.Controls("ComboBox1").Value \'获得接收用户名

Dim bm As String = e.Form.Controls("ComboBox2").Value \'获得接收部门名称

Dim cn As String = e.Form.Controls("TextBox1").Value \'获得发送内容

If re = "" OrElse cn = "" Then

    MessageBox.Show("信息不完整,信息无法发送!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

    Return

End If

If re = QQClient.UserName  Then

    MessageBox.Show("不能给自己发信息!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

    Return

End If

Dim fsz As String

fsz=bm & "." &  re

QQClient.Send(fsz,cn)

e.Form.Controls("TextBox1").Value = ""

<!--EndFragment-->
--  作者:大红袍
--  发布时间:2015/11/8 22:08:00
--  

呃,没什么问题啊


--  作者:xianzheng
--  发布时间:2015/11/8 22:22:00
--  
 If re = QQClient.UserName  Then 这行代码有问题,运行无效
--  作者:xianzheng
--  发布时间:2015/11/8 22:27:00
--  
 re是接收者,如果接收者等于openQQ登陆者时提示“不能给自己发信息!",但现在问题是If re = QQClient.UserName 运行无效,发给自已的也没有任何提示信息
--  作者:大红袍
--  发布时间:2015/11/9 9:21:00
--  

你msgbox看一下username的值吧,可能和你预想的不一样。

 

msgbox(QQClient.UserName)


--  作者:xianzheng
--  发布时间:2015/11/9 9:46:00
--  
 好的
--  作者:xianzheng
--  发布时间:2015/11/9 10:20:00
--  
原因找出来了,应该改 If fsz = QQClient.UserName  Then
--  作者:xianzheng
--  发布时间:2015/11/9 10:55:00
--  

不过现在又新的问题:如果在线,接收到信息的同时,"信息"表马上增加一行新的记录,如果原来不在线,上线后信息是可以接收到的,但"信息"表没有添加任何记录,不知道什么原因?

Dim dr As DataRow = DataTables("信息").AddNew
dr("发送者") = iif(e.UserName > "",e.UserName,"服务器")
dr("接收者") = _UserName
dr("发送时间") =iif(e.UserName > "",Date.Now(),"服务器")
dr("接收时间") = Date.now()
dr("内容") = e.Message
popMessage(e.Message,"提示",PopiconEnum.Infomation)
DataTables("信息").Save() \'保存

[此贴子已经被作者于2015/11/9 10:55:12编辑过]

--  作者:大红袍
--  发布时间:2015/11/9 11:00:00
--  

呃,你代码是卸载QQClient里面的吗?

 

加入msgbox看一下是否弹出对应信息。

 

http://www.foxtable.com/help/topics/2977.htm

 


--  作者:Hyphen
--  发布时间:2015/11/9 11:01:00
--  

内置聊天窗口不会触发接收事件,必须用代码发送才行

http://www.foxtable.com/help/topics/2976.htm