十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Private Const WM_SETTEXT = HC
创新互联建站于2013年开始,先为南票等服务建站,南票等地企业,进行企业商务咨询服务。为南票企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As System.Text.StringBuilder) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As String = "王小明"
Dim build As New System.Text.StringBuilder(s.Length)
build.Append(s)
SendMessage(TextBox1.Handle, WM_SETTEXT, 0, build)
End Sub
'vb.net的串口接收数据要用到委托
Delegate Sub SetTextCallback(ByVal InputString As String) '声明一个委派类,并声明符合函数参数有一个,而其型态是字符串
Private Sub ShowString(ByVal comData As String)
txt_Re.Text = comData '将收到的数据入接收文字框中--- txt_Re.Text 是接收用的文本框
txt_Re.SelectionStart = txt_Re.Text.Length
txt_Re.ScrollToCaret()
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived‘自动接收事件
Dim inData As String = SerialPort1.ReadExisting
Dim d As New SetTextCallback(AddressOf ShowString)
Invoke(d, inData)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '发送指令
SerialPort1.Write("123")
End Sub
你不用程序的情况能不能用TAB切换焦点。如果这样不行的话你用程序控件是没用的。
或都直接对第二个编辑框发送消息。
如果你家里是公网ip或者公网IP能映射内网IP的话可以直接搭一个服务器,否则只能使用内网穿透软件然后再搭建服务器。如应用服务器、网页服务器、电子邮件服务、 FTP 服务器等等都可以进行消息交流。