<script type="text/javascript">
</script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
串口接收过程中怎样将末尾3位字符数据去掉?
代码如下:
数据显示为999.9E+0 ,怎样把后面的E+0去掉?
Public Sub ReceiveSerialData_GR()
Dim iReceivedbytes As Integer, i As Integer
Dim bReadByte() As Byte
Dim SendReady As Boolean
Dim strReceiveBytes As String
Try
SerialPort1.PortName = COM1
SerialPort1.Open()
SerialPort1.RtsEnable = True
SerialPort1.Write(Order + vbCrLf)
SendReady = SerialPort1.CtsHolding
Thread.Sleep(100)
If SendReady = True Then
MsgBox( Ready )
Else
MsgBox( Not Ready )
End If
iReceivedbytes = SerialPort1.BytesToRead buffer中所有字节数
ReDim bReadByte(iReceivedbytes - 1)
SerialPort1.Read(bReadByte, 0, iReceivedbytes)
For i = 0 To iReceivedbytes - 1
strReceiveBytes = CStr(bReadByte(i))
strReceiveBytes = Asc(bReadByte(i) + 32)
Aod = Chr(IIf(Len(strReceiveBytes) > 1, strReceiveBytes, 0 & strReceiveBytes) & )
MsgBox(Aod)
TextBox1.Text = TextBox1.Text + Aod
TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text, 14)
Next
MsgBox(SerialPort1.ReadChar)
If iReceivedbytes > 0 Then
TextBox1.Text = TextBox1.Text + SerialPort1.ReadChar
Else
SerialPort1.RtsEnable = False
SerialPort1.Close()
End If
Catch ex As Exception
MsgBox( 接收失败 )
End Try
End Sub
__________________________________________________________________________
坐个沙发不容易啊..up
__________________________________________________________________________
自己顶一下 !
__________________________________________________________________________
看看
__________________________________________________________________________
接完了SubString
__________________________________________________________________________
说的详细点好么?
__________________________________________________________________________
str为你接收后的字符
str.Substring(0,str.LastIndexOf( E ));
__________________________________________________________________________
可能大小写上有点问题,到IDE中写一下就可以了。
__________________________________________________________________________
str1为你接收后的字符
p as integer
p=str1.length-3
str1.substring(0,p)
__________________________________________________________________________
xuexi
__________________________________________________________________________
串口接收过程中怎样将末尾3位字符数据去掉?
代码如下:
数据显示为999.9E+0 ,怎样把后面的E+0去掉?
Public Sub ReceiveSerialData_GR()
Dim iReceivedbytes As Integer, i As Integer
Dim bReadByte() As Byte
Dim SendReady As Boolean
Dim strReceiveBytes As String
Try
SerialPort1.PortName = COM1
SerialPort1.Open()
SerialPort1.RtsEnable = True
SerialPort1.Write(Order + vbCrLf)
SendReady = SerialPort1.CtsHolding
Thread.Sleep(100)
If SendReady = True Then
MsgBox( Ready )
Else
MsgBox( Not Ready )
End If
iReceivedbytes = SerialPort1.BytesToRead buffer中所有字节数
ReDim bReadByte(iReceivedbytes - 1)
SerialPort1.Read(bReadByte, 0, iReceivedbytes)
For i = 0 To iReceivedbytes - 1
strReceiveBytes = CStr(bReadByte(i))
strReceiveBytes = Asc(bReadByte(i) + 32)
Aod = Chr(IIf(Len(strReceiveBytes) > 1, strReceiveBytes, 0 & strReceiveBytes) & )
MsgBox(Aod)
TextBox1.Text = TextBox1.Text + Aod
TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text, 14)
Next
MsgBox(SerialPort1.ReadChar)
If iReceivedbytes > 0 Then
TextBox1.Text = TextBox1.Text + SerialPort1.ReadChar
Else
SerialPort1.RtsEnable = False
SerialPort1.Close()
End If
Catch ex As Exception
MsgBox( 接收失败 )
End Try
End Sub
__________________________________________________________________________
坐个沙发不容易啊..up
__________________________________________________________________________
自己顶一下 !
__________________________________________________________________________
看看
__________________________________________________________________________
接完了SubString
__________________________________________________________________________
说的详细点好么?
__________________________________________________________________________
str为你接收后的字符
str.Substring(0,str.LastIndexOf( E ));
__________________________________________________________________________
可能大小写上有点问题,到IDE中写一下就可以了。
__________________________________________________________________________
str1为你接收后的字符
p as integer
p=str1.length-3
str1.substring(0,p)
__________________________________________________________________________
xuexi
__________________________________________________________________________