3, use Clothes Handle function close string line communication
This method communication code is as follows:
The Dim ComDev, Err, Errl, bWriteState, dwBytesRead,dwBytesRead As Long
The ComDev = CreateFiles("COM 1", GENERIC-READ|GENERIC -WRITE, 0, NULL,
OPEN -EXISTING, FILE -ATTRIBUTE NORMAL, NULL) open COM 1
The if ComDev=-1 ThenMsgbox"can not open in a string of line":Exit Sub
Err= SetupComm(hComDev, 1024, 512), establish to place the size of receiving the buffer area and exportation buffer area
The GetCommState(hComDev, &cb)'return the constitution circumstance of current string of
dcb .BaudRate=2400'the wave lead to 2400 bpses especially
dcb .f Parity=NOPARITY'have no strange accidentally the school check
Dcb.ByteSize=7'data is 7
dcb . StopBits=1'establish a stop
Errl =SetCommStates'( hComDev, & dcb)DCB the contents within structure write to establish toward the string
Do Events
The bWrite State= WriteFile(hComDev,1plnBuffer, 1, dwBytesRead, NULL)'send out
B.原文的翻译
翻译的资料:
VB环境下计算机与全站仪的数据通讯方法 论文网
电子全站仪由于其功能强大,操作方便,大大提高了野外作业效率。因此它正逐步取代传统的测量仪器被推广应用。虽然利用全站仪本身的系统菜单功能即可完成常规测量作业,但在大坝安全监测、边坡变形监测等这种数据量较大、需实时处理数据的应用场合,单靠仪器本身的功能和内存量将不能满足要求。此时可将数据通过仪器的数据输出端口输出到计算机,并由软件对数据进行处理和存储。随着计算机的广泛使用,目前国内许多野外数字测图也要实现数据的实时转输。VB是由微软公司推出的基于Windows的可视化编程语言,它采用面向对象、事件驱动的程序设计方法,操作简便,因此倍受程序设计人员的青睐。下面就以Leica Tc2002全站仪为例,介绍如何在VB 6. 0环境下利用mscomm控件和Windows API函数实现计算机与全站仪的数据通讯。 VB编程英文文献和翻译(3):http://www.youerw.com/fanyi/lunwen_27782.html