vb 2005 串口实时接收数据的问题 - .NET技术 / VB.NET
我是vb.net的菜鸟
现在需要通过串口接收一个电表的数据,该数据一帧共有14个字节,数据开始第一个字节为帧开始标志(是16进制的‘13’),剩下13个字节需要实时显示出来。
我找了个vb6.0的代码,自己改成vb2005的。
大家帮忙看一下对不对?
谢谢了
vb2005的代码
Public Class Form1
Private ReadByte(12) As Byte
Private AfByte(0) As Byte
Private zahler As Integer
--------------------------------------------------------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SerialPort1.IsOpen Then
SerialPort1.Close()
End If
Try
With SerialPort1
.PortName = ComboBox1.Text
.ReceivedBytesThreshold = 1
.DiscardInBuffer()
.DiscardOutBuffer()
zahler = 0
'.BaudRate = 2400
'.Parity = IO.Ports.Parity.None
'.DataBits = 8
'.StopBits = IO.Ports.StopBits.One
' .Encoding = System.Text.Encoding.Unicode
End With
SerialPort1.Open()
Button1.Enabled = False
&nbs
相关问答:
为什么我用form.show和form.hide多次连接了两个窗口只能互换链接两次啊?
代码看看
照道理form.show 没次数限定的吧
我也快疯了。
楼主知道怎么发贴么?
引用
我也快疯了。
楼主知道怎么发贴么?
楼主也 ......
我想把word另存为xml之后,用vb读取这个xml的内容,请问如何实现?
dim f as integer
dim b() as byte
dim s as string
dim L as long
f=freefile()
open "abc.xml" for binary access read as #f
......
我想用VB做一个OCX(纯菜鸟,临时需要用VB做点东西,特来请教),A用户(IP:192.168.0.1)与B用户(IP:192.168.0.2)进行点对点的发送接收消息
要求采用OCX方式,比如A用户知道B用户IP,我直接传参(B的IP)至OCX ......
谁能帮我把下面这些代码改成VB形式的,多谢了,急用~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[],float g ......