采用DLL动态连接库调用是可以的,其实就是一些接口定义或者经过VB编译过的代码,如果你仅仅针对2010进行数据解释的话,用不着采用DLL调用。你可以这么做,在数据窗口中,建立一个表单,上面有各种数据的文本框,然后增加一个MSCOMM控件,在MSCOMM控件中定义接口方式,并在缓冲区中接受串口发来的数据,这些数据是有规律的排列的,例如从开始第N个字节到N+D个字节是日期,那么这个D就是日期,写入表单日期文本框,再往下S+Z个字节是标本号,那么这个Z就写入标本序号文本框,依此类推,将全部数据逐次写入各自的文本框中。这一步叫读取数据,然后校验读取的数据是否完整,也就是说是否是规定的串口发过来的字节数,如果是就长度校验完成,第二步校验是验证各个数据的真实性,例如,日期不会是以前的时间,各个项目的数据不会是0或者负数等等,这样完成整个校验。在完成校验后,利用代码将接收到的数据按照各自的数据格式写入数据库各个相应的字段,并且刷新屏幕,这样就完成了数据接收、显示、存储工作,至于查询和其他功能你自己添加就是。
Adopt DLL development connection warehouse invoking to be allowed, the code in fact, have it is a few interfaces to define or compiling and translating process VB, It is not worthwhile adopt DLL invoking if you carry out the data explain only specifically for 2010 .
You can be composing, in data window like this middle , build a form , higher authority version frame having various data , increase by and then a MSCOMM control , define the interface way in MSCOMM control , accept and the data to come string hair in buffer area,These data are to arrangement having law , the byte arrives at N + D for instance from N starting a mansion the byte is date , so such D is date , white in the form Shan date version frame, the byte is a specimen number again to time of S + Z , so such Z moves towards the write-in specimen serial number version frame, on the analogy of this, in the version frame writing all data in each gradually.
This single-step shouts fetch data, and then the data that check fetches is entire or not, just say being that the string stipulating that sends out the byte number coming over or not, second step checkings are the authenticities verifying each data , for instance, date can not be before time , one by one, the project data is 0 not likely or the minus accomplishes the entire checking wait a minute , such if being that the length checking is completed right away.
Behind accomplishing a checking, make use of a code to will receive the syllable, and redraw one by one corresponding according to respective data form write-in data base to the data, such has accomplished the data taking-over right away , display , memory have worked , drawn as for inquiry other function yourself's addition will be. |