易截截图软件、单文件、免安装、纯绿色、仅160KB

在VB中利用API进行串口通信


       一般来说,在VB中编写串口通讯程序,首先考虑到是使用MSComm控件,可是该控件不能设置超时,而且对许多内部的参数进行了隐藏,从而不能满足有些具体的工作。而使用API进行串口通信,大多是使用VC,很少见到完整的VB代码,为此,我编写了这个模块。
      同时,由于串口通信是基于字节流的,为方便程序设计,还编写了三个简单的辅助函数,并写了一个详细的测试代码。
      具体代码如下:
Option Explicit  
Option Base 0  
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) As Long
Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const GENERIC_READ = &H80000000  
Private Const GENERIC_WRITE = &H40000000  
Private Const OPEN_EXISTING = 3  
Private Const INVALID_HANDLE_VALUE = -1  
Private Declare Function GetCommState Lib "kernel32" (ByVal nCid As Long, lpDCB As DCB) As Long
Private Declare Function SetCommState Lib "kernel32" (ByVal hCommDev As Long, lpDCB As DCB) As Long
Private Declare Function SetCommTimeouts Lib "kernel32" (ByVal hFile As Long, lpCommTimeouts As COMMTIMEOUTS) As Long
Private Declare Function SetupComm Lib "kernel32" (ByVal hFile As Long, ByVal dwInQueue As Long, ByVal dwOutQueue As Long) As Long
Private Declare Function PurgeComm Lib


相关文档:

VB.NET2005读取XML数据

通过调用CreateDataSetfromXml取得XML数据
Imports System.Xml
Public Const FILE_CONFIG = "MZZ.xml"
Public Const PATH_CONFIG = "\XML\"
Dim dstXML As DataSet
Dim tblXML_DB As DataTable
Dim dtCod As New DataTable
Dim strSQL As String = ""

clsPublic ......

用VB Winsock控件创建TCP/IP客户机/服务器程序


转自:http://www.52arm.com/Article_Show.asp?ArticleID=186
 
作者:weidian    ---本站原创    点击数:4721    发表时间:2008-5-7    编辑:sanzang
 
Winsock控件建立在TCP、UDP协议的基础上,完成与远程计算机的 ......

Vb中窗体自定义坐标


开始使用vb的时候喜欢用手画出那个控件的位置.然后一个一个的拖动,一点一点的移动.直到感觉满意了为止.如果是控件多了这个就很麻烦了
一不小心可能会将谋个控件拖到一边去
所以,我们在以后的作品中
尽量使用代码来定义控件位置,,要灵活的掌握坐标位置.,可以使用自定义坐标.使用像素来更好的来分区显示控件.
 
& ......

详解VB调用C#类库的方法步骤(转载)

使用c#语言在.net平台生成的dll是基于MSIL的二进制代码,通常情况下是无法被native的语言和程序调用的(例如vb,vc,delphi)。但是一般来说windows上native的程序都是可以直接使用com对象的。通过.net平台提供的一些工具,可以为其伪造一个com接口并注册到系统中。此时,可以在native的程序里,通过这个伪com接口来实现此. ......

vb shell 应用程序

就这么一个函数就解决了那位仁兄3天多的工作
唉~!真被一个函数玩死了
这里顺便帖出来吧
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Microsoft.VisualBasic.Shell( ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号