[.NET] RS232字串的接收

看板Visual_Basic作者 (左手)時間14年前 (2011/10/11 15:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
Imports System.IO.Ports Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SerialPort1.Open() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click SerialPort1.Close() End Sub Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Dim buff() As Byte Dim s As String = "" ReDim buff(SerialPort1.BytesToRead - 1) SerialPort1.Read(buff, 0, buff.Length) For i As Integer = 0 To buff.Length - 1 s += buff(i).ToString("X2") If i < 22 Then i = i + 1 End If Next ListBox1.Text = ListBox1.Text & s & vbCrLf End Sub End Class ---------------------------------- 以上跑的時候沒錯 可是收不到檔案 不知道要怎麼修改 請大師幫忙@@ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.121.150.186
文章代碼(AID): #1Ea-dW80 (Visual_Basic)