VB6 中创建一个主窗体工程后,再添加一个 ActiveX用户控件工程
在用户控件窗体中可以添加 文本框和按钮的控件
属性
Public strUrl As String
方法
'发送消息 Public Sub WebSocketSendMsg(ByVal SendMsg As String) On Error GoTo ErrTrap 'Dim sMsg As String 'sMsg = msgInput.Text Call ShowMsg("Send " & SendMsg) '显示消息 If SendMsg <> "" Then websock.send (SendMsg) End If Exit Sub
事件
定义事件
Public Event eCtiWebSocketOpen(ByVal strMsg As String) 'WebSocket Open
执行事件
Private Sub websock_onopen() Dim sMsg As String sMsg = "OnOpen" Call ShowMsg(sMsg) '显示消息 '事件 RaiseEvent eCtiWebSocketOpen(sMsg) Exit Sub
在主窗体工程中添加 此用户控件
将控件加到部件中
将用户控件拖到 窗体上
调用用户控件的方法
Private Sub butOpen_Click() Call Me.CtiClient1.WebSocketOpen End Sub Private Sub butClose_Click() Call Me.CtiClient1.WebSocketClose End Sub
用户控件的事件
'用户控件 连接成功 Private Sub CtiClient1_eCtiWebSocketOpen(ByVal strMsg As String) strMsg = strMsg & Chr(13) & Chr(10) Me.msgListboxCti.Text = Me.msgListboxCti.Text & strMsg End Sub
'用户控件 关闭 Private Sub CtiClient1_eCtiWebSocketClose(ByVal strMsg As String) strMsg = strMsg & Chr(13) & Chr(10) Me.msgListboxCti.Text = Me.msgListboxCti.Text & strMsg End Sub
生成OCX
标签:Me,控件,Sub,sMsg,strMsg,OCX,VB6,String From: https://www.cnblogs.com/hailexuexi/p/16771528.html