【正文】
close an equipments sentence handleThree, end languageIn the VB under environments in two kinds of methods of development string line munication procedure, make use of API the function write a string of munication procedure more plicated, need to have a certain plait distance experience, its advantage is to carry out function more abundant, application noodles more extensive, more plicated munication functi。send outResultRead File(hComDev, 1 pinBuffer, 1, dwBytesRead, NULIJ39。( hComDev, amp。data is 7dcb . StopBits=139。the wave lead to 2400 bpses especiallydcb .f Parity=NOPARITY39。cb)39。t suitable for our requests. We can use Windows at this time API provides of munication function to carry out can transplant sex strong string of line of munication procedure with writing. Windows 98 correspondence the system provided the string of an improvement line application the procedure pick up a people API to use to carry on handing over type string with each other line correspondence. Among them, string the and other correspond by letter an equipments is a document to carry on the processed, open, close, reading of string and write in the function used similar to the function of the operation document.Before adjusting to use APIA function, have to the first essentials pronouncement change to measure and function.Dim dcb As DCBDim ofstructl As OFSTRUCTDim operport As LongOpen an API text to originally look into a machine in the V B wreath territory bottom, open Win32. Txt document, atpronouncementing can the options win election in OpenFilc and Setup Cornm, Setup CommState and ReadFile, WriteFile, CIoscHand, le etc. function, in type can the options win election in DCB, OVERLAPPED etc. structure, in constant can the options win election in ODDPARITY, EVRXCHAR etc. often quantity, then choose a replication, make duplicate them to the scrapbook, and glue to stick application procedure code in. Adjust to carry on a string of line munication with API in the VB timeses:1,adjust to use CreateFile line munication first carry on a beginning to start to turn to the string. CreateFile function for read an interview or write an interview to beatOpen a string of, return to that string of sentence handle after opening successfully, then adjust to use SetComm function is in a string of line allotment buffer area size, provide to read and write a string of usage, immediately after use DCB the structure change to measure a constitution to need to change the munication parameter of lacking the string line of saving the value, such as wave especially rate, strange accidentally the school check a , data, stop.2,adjust to use Write File, the Read File function carries on reading and writing an operation to the string line. Carry on a data to send out with Write File, for synchronous I/O operation, its last parameter can be NULL, but tread an I/O operation to the difference, its last parameter musts be a direction OVERLAPPED structure of point needle, make reading and writing of data the operation carry on in the backstage and pass this OVERLAPPED39。establish Buffer area sizeThe MS CommlPortOpen=True39。constitution or return to receive to use Input inside the buffer area an attribute to read the person39。2400, , IP139。the constitution string go a municationThe MS CommlSettings=39。The affairs drives a way from Windows 98 notice applied the procedure some affairs when take place, then according to the matter taken place The feeling es to carries on an operation to the string. These two kinds of methods each beneficial fraud and oneself apply of realm, so in the different correspondence system, can according to the dissimilarity39。Input Len: constitution or return to Input to read the word stanza of each time number。Out Buffer Size: send out the size of buffer area。Input: from receive buffer area to read data。Portpopen: constitution or return to a string of munication appearance of。s with Leica Tc 2002 whole station instrument for example, introduce how to carry out the munication between puter and totalstation in the VB 6. 0 environment by making use of msm and the function of Windows API One,usage MSComm control a piece VB provided an ActiveX to control Communication of a Microsoft Control, brief name MS Common controlled a piece, customer can at own of imbed MSComm to control a piece in the applied procedure, should control a piece to deliver and receive a data through a string of line port, for applied the procedure provide a string of line munication function. Choose VB engineering menus, open parts dialog box, pick out Microsoft Comm Control , can immediately control the piece to the msm and add a box of controlling of person VB. The msm that may use controls the attribute of piece to have several followings:The CommPort: the constitution string go slogan。打開通信口If Err Then 39。串口每收到1字節(jié)的數(shù)據(jù),即產(chǎn)生接收中斷If Not .PortOpen Then 39。波特率為XXXXX,無檢驗,8位數(shù)據(jù),1位停止位.InBufferSize = 1024.OutBufferSize = 1024.InputMode = 0 39。If = True ThenMsgBox 對不起,沒有你查找的記錄!End IfEnd SubPrivate Sub Form_Load() = amp。 Sto_Find_SP amp。 Else MsgBox 請輸入商品號 Exit Sub End If If Then MsgBox 沒有該商品: Exit Sub With MSFlexGrid1 If .TextMatrix(1, 1) Then .AddItem , .Row + 1 .Row = .Row + 1 End If .TextMatrix(.Row, 0) = (商品條形碼) .TextMatrix(.Row, 1) = (商品名稱) .TextMatrix(.Row, 2) = (價格) .TextMatrix(.Row, 3) = (數(shù)量) .TextMatrix(.Row, 4) = (合計) .TextMatrix(.Row, 3) = Val() temp = (價格) * Val() .TextMatrix(.Row, 4) = Val(temp) End With Text2 = Clear End IfEnd SubPrivate Sub Timer1_Timer() = TimeEnd Sub商品入庫系統(tǒng)程序Dim GotStr As StringDim MyStr As StringPrivate Sub bc_Click()End SubPrivate Sub Command1_Click()End SubPrivate Sub Find_Click()Dim Sto_Find_SP As StringSto_Find_SP = InputBox(請輸入條形碼:, 查找) 商品條形碼=39。Persist Security Info=False