大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net网口通信,vbnet接口

VB与VB.NET串口及以太网通迅

关于串口通讯的问题:

成都创新互联10多年企业网站制作服务;为您提供网站建设,网站制作,网页设计及高端网站定制服务,企业网站制作及推广,对建筑动画等多个方面拥有多年的网站推广经验的网站建设公司。

很明显,你还不知道(不会、不习惯)使用事件驱动的方式接收数据。

建议你仔细看看串口组件(无论VB6还是VB.net)的OnComm事件,你的问题很容易解决。

关于以太网通讯:

在TCP通讯中端口确实可以重用,你百度一下“TCP端口重用”能查到很多示例。

但绝大多数情况下不推荐端口重用,而应该采取服务器端建立连接池的方法。

或者,干脆不用TCP,用UDP解决也可以。

请教用VB.NET向网口发送16进制的数的方法.

很有意思。

原文数据全为:“00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ”

加密后变成了:“09 51 55 F4 FB 10 6F A4 D3 E8 87 46 F8 2F 49 CD ; ”

得出这样的结果是有很多方法都可以实现的:

比如每个原数上加上个常数就可以了。

00+09=09;得出第一组加密后的数值

00+51=51;得出第二组加密后的数值

...

00+CD=CD;得出第16组加密后的数值.

加密的方法还有很多,不过这种最简单。

还有就是你给的原文太单一了,不能够更好的分析数据的规律。

如果你能把原文改为如下这段代码再去加密一下,再把加密结果贴上来看一下就好多了。

00000140h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ;

00000150h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ;

00000160h: 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 ; 00000170h: 00 10 20 30 40 50 60 70 80 90 A0 B0 C0 D0 E0 F0 ;

00000180h: 11 11 11 11 11 22 22 22 22 22 22 EE EE EE FF FF ;

以上是单片机高手团为您解答。

如果还没解决你的问题,可以加我百度HI账号。

用vb.net实现网络通信

用 vb.net socket通信

Dim th As Threading.Thread

2 Dim tcpl As System.Net.Sockets.TcpListener

3

4 Private Sub Form1_Load()Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

5 th = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MyListen))

6 th.Start()

7 End Sub

8

9 Public Sub SendMessage()Sub SendMessage(ByVal IP As String, ByVal SendMsg As String)

10 Try

11 If IP "" Then

12 Dim tcpc As New System.Net.Sockets.TcpClient(IP, 5656)

13 Dim tcpStream As Net.Sockets.NetworkStream = tcpc.GetStream

14 Dim reqStream As New IO.StreamWriter(tcpStream)

15 reqStream.Write(SendMsg)

16 reqStream.Flush()

17 tcpStream.Close()

18 tcpc.Close()

19 End If

20 Catch ex As Exception

21 MsgBox(ex.Message.ToString)

22 End Try

23 End Sub

24 Private Sub MyListen()Sub MyListen()

25 Try

26 Dim ipAddress As System.Net.IPAddress = System.Net.Dns.Resolve(System.Net.Dns.GetHostName).AddressList(0)

27 tcpl = New System.Net.Sockets.TcpListener(ipAddress, 5656)

28 tcpl.Start()

29 While True

30 Dim s As System.Net.Sockets.Socket = tcpl.AcceptSocket()

31 Dim MyBuffer(1024) As Byte

32 Dim i As Integer

33 i = s.Receive(MyBuffer)

34 If i 0 Then

35 Dim lstrRec As String

36 Dim j As Integer

37 For j = 0 To i - 1

38 TextBox1.Text += Chr(MyBuffer(j)) ","

39 Next

40 End If

41 End While

42 Catch ex As Exception

43 MsgBox(ex.Message.ToString)

44 End Try

45 End Sub

46

47 Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

48 SendMessage("192.168.0.61", TextBox2.Text)

49 End Sub

请教,VB怎样与网口进行通信

使用Winsock控件进行的

Public Function f(ByVal x As Double) As Double

Dim y As Double

y = x ^ 3 - 5 * x ^ 2 + 16 * x - 80

Return y

End Function

Public Function xpoint(ByVal x1 As Double, ByVal x2 As Double) As Double

Dim x As Double

x = (x1 * f(x2) - x2 * f(x1)) / (f(x2) - f(x1))

Return x

End Function

Public Function root(ByVal x1 As Double, ByVal x2 As Double) As Double

Dim x As Double, y1 As Double, y As Double

y1 = f(x1)

Do

x = xpoint(x1, x2)

y = f(x)

If y * y1 0 Then

y1 = y

x1 = x

Else

x2 = x

End If

Loop Until y = 0.0001

Return x

End Function

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

Dim st As String = "", pb As Integer = 11, sum As Integer = 0

Dim f1 As Double, f2 As Double, x As Double, x1 As Double, x2 As Double

Do

x1 = Val(InputBox("请输入第一个数字"))

x2 = Val(InputBox("请输入第二个数字"))

f1 = f(x1)

f2 = f(x2)

Loop Until f1 * f2 = 0

x = root(x1, x2)

TextBox6.Text = x.ToString

End Sub


分享名称:vb.net网口通信,vbnet接口
当前路径:http://dzwzjz.com/article/dsgjpso.html
在线咨询
服务热线
服务热线:028-86922220
TOP