一、如何使用dll库:

  dll库是动态链接库,一般是别人提供的,用来做二次开发,相当于别人把一些函数包装在dll中,已经生成可以链接文件,你只能调用,但是不能看到方法的实现。所以给你提供dll的人一般也会提供dll的库函数说明,说明中会告诉你里面的函数的返回值,参数等一些东西。

  1、要使用dll库中的方法,首先把dll复制粘贴在你的.net项目中的\bin\Debug路径下面。

  2、在项目中新建一个模块Module,然后在里面声明要用的函数。例如:我新建一个叫API的模块,然后声明函数,具体过程如下:

  

Imports System.Text
Module API '驱动加载函数
Public Declare Function RDR_LoadReaderDrivers Lib "rfidlib_reader.dll" (ByVal path As String) As Integer
Public Declare Function RDR_GetLoadedReaderDriverCount Lib "rfidlib_reader.dll" () As Integer '设备连接、断开函数
Public Declare Function RDR_Open Lib "rfidlib_reader.dll" (ByVal connstr As String, ByRef hr As UIntPtr) As Integer
Public Declare Function RDR_Close Lib "rfidlib_reader.dll" (ByVal hr As UIntPtr) As Integer '获取错误代码
Public Declare Function RDR_GetReaderLastReturnError Lib "rfidlib_reader.dll" (ByVal hr As UIntPtr) As Integer '
Public Declare Function RDR_GetTagDataReportCount Lib "rfidlib_reader.dll" (ByVal hr As UIntPtr) As UInt32 '以下是读取读卡器参数的函数
Public Declare Function RDR_GetReaderInfor Lib "rfidlib_reader.dll" (ByVal hr As UIntPtr, ByVal Type As Byte, ByRef buffer As StringBuilder, ByRef nSize As UInt32) As Integer '以下是盘卡函数
Public Declare Function RDR_CreateInvenParamSpecList Lib "rfidlib_reader.dll" () As UIntPtr
Public Declare Function ISO15693_CreateInvenParam Lib "rfidlib_aip_iso15693.dll" (ByVal hInvenParamSpecList As UIntPtr, ByVal AntennaID As Byte, ByVal en_afi As Byte, ByVal afi As Byte, ByVal slot_type As Byte) As UIntPtr
Public Declare Function RDR_TagInventory Lib "rfidlib_reader.dll" (ByVal hr As UIntPtr, ByVal AIType As Byte, ByVal AntennaCount As Byte, ByRef AntennaIDs As Byte, ByVal InvenParamSpecList As UIntPtr) As Integer 'AntennaIDs传入数组的第一个元素地址
Public Declare Function RDR_GetTagDataReport Lib "rfidlib_reader.dll" (ByVal hr As UIntPtr, ByVal Seekpos As Byte) As UIntPtr
Public Declare Function ISO15693_ParseTagDataReport Lib "rfidlib_aip_iso15693.dll" (ByVal hTagReport As UIntPtr, ByRef aip_id As UInt32, ByRef tag_id As UInt32, ByRef ant_id As UInt32, ByRef dsfid As Byte, ByRef uid As Byte) As Integer '以下是销毁盘点参数列表
Public Declare Function DNODE_Destroy Lib "rfidlib_reader.dll" (ByVal dn As UIntPtr) As Integer '盘点卡的两个宏定义
Public Const RFID_SEEK_FIRST =
Public Const RFID_SEEK_NEXT = '连接卡
Public Declare Function ISO15693_Connect Lib "rfidlib_aip_iso15693.dll" (ByVal hr As UIntPtr, ByVal tagType As UInt32, ByVal address_mode As Byte, ByVal uid() As Byte, ByRef ht As UIntPtr) As Integer '读卡
Public Declare Function ISO15693_ReadMultiBlocks Lib "rfidlib_aip_iso15693.dll" (ByVal hr As UIntPtr, ByVal ht As UIntPtr, ByVal readSecSta As Byte, ByVal blkAddr As UInt32, ByVal numOfBlksToRead As UInt32, ByRef numOfBlksRead As UInt32, ByRef bufBlocks As Byte, ByVal nSize As UInt32, ByRef bytesBlkDatRead As UInt32) As Integer '写卡
Public Declare Function ISO15693_WriteMultipleBlocks Lib "rfidlib_aip_iso15693.dll" (ByVal hr As UIntPtr, ByVal ht As UIntPtr, ByVal blkAddr As UInt32, ByVal numOfBlks As UInt32, ByVal newBlksData() As Byte, ByVal bytesToWrite As UInt32) As Integer Public Declare Function LSG_CmdGetReports Lib "rfidlib_LSGate.dll" (ByVal hr As Long, ByVal Flag As Byte, ByVal recordsToGet As Byte) As Integer
Public Declare Function LSG_ParseSCEventData Lib "rfidlib_LSGate.dll" (ByVal hr As Long, ByVal slData As String, ByVal nSize As Long, ByRef dir As Byte, ByRef m_time As Byte) As Integer
Public Declare Function LSG_CmdGetCurrentFlowOfPeople Lib "rfidlib_LSGate.dll" (ByVal hr As Long, ByRef inFlow As Long, ByRef outFlow As Long) As Integer
Public Declare Function LSG_CmdResetFlowOfPeople Lib "rfidlib_LSGate.dll" (ByVal hr As Long, ByVal mFlg As Byte) As Integer
Public Declare Function LSG_CmdReverseDirection Lib "rfidlib_LSGate.dll" (ByVal hr As Long) As Integer
Public Declare Function LSG_CmdGetSystemTime Lib "rfidlib_LSGate.dll" (ByVal hr As Long, ByRef year As Long, ByRef month As Byte, ByRef day As Byte, ByRef hour As Byte, ByRef minute As Byte, ByRef second As Byte) As Integer
Public Declare Function LSG_CmdSetSystemTime Lib "rfidlib_LSGate.dll" (ByVal hr As Long, ByVal year As Long, ByVal month As Byte, ByVal day As Byte, ByVal hour As Byte, ByVal minute As Byte, ByVal second As Byte) As Integer Public Declare Function MultiByteToWideChar Lib "kernel32 " (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
Public Declare Function WideCharToMultiByte Lib "kernel32 " (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long
Public Const CP_ACP = ' default to ANSI code page
Public Const CP_UTF8 = ' default to UTF-8 code page End Module

声明完的函数我就可以在项目中调用了,例如:

     '设备连接串
Dim connStr = "RDType=RD201;CommType=COM;COMName=" + CmboxcommCanBeUse.SelectedItem + ";BaudRate=38400;Frame=8E1;BusAddr=255"
Dim connectOK As Integer =
connectOK = RDR_Open(connStr, hr)

以上代码中的RDR_Open()函数就是在API模块中声明的,函数所在的位置是rfidlib_reader.dll中。

二、常用的一些方法:

Now()     获取当前日期时间,

Format() 格式化日期时间函数:

 Format(Now(), "yyyy-MM-dd-hh-mm-ss")

DataGridView用法:

GoodDataGridView.Rows.Add()为添加一行

GoodDataGridView.Rows.RemoveAt(1) 为删除第一行

GoodDataGridView(0, 0).Value = "序号"   为给某列某行的单元格设置值。其中(0,0)中前面的数字代表第几列,后面的数字代表第几行。
     GoodDataGridView.Rows.Add()
GoodDataGridView(, ).Value = "序号"
GoodDataGridView(, ).Value = "商品编码"
GoodDataGridView(, ).Value = "商品名称"
GoodDataGridView(, ).Value = "商品价格"

定义数组并初始化:

      '定义一组商品的属性的二进制编码,用来保存当前连接的标签的内容
Dim goodsNumb() As Byte = {, , , , , , , , , , , , , , , , , , , }
Dim goodsName() As Byte = {, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , }
Dim goodsPric() As Byte = {, , , , , , , , , , , , , , , }

UTF8 编码与解码:

Imports System.Text

Module UTF8

    'UTF8编码函数
Public Function StringToUTF8Bytes(ByVal strData As String) As Byte() Dim bytes() As Byte
bytes = Encoding.UTF8.GetBytes(strData)
Return bytes End Function 'UTF8解码函数
Public Function UTF8BytesToString(ByVal strData() As Byte) As String Dim retstring As String
retstring = Encoding.UTF8.GetString(strData)
Return retstring End Function End Module

datagridview隔行显示不同的颜色:

datagridview1.RowsDefaultCellStyle.BackColor = Color.Bisque

datagridview1.AlternatingRowsDefaultCellStyle.BackColor =Color.Beige

datagridview设置标题字体样式:

设置ColumnHeaderDefaultCellStyle的Font属性
或者编程
datagridview.Columns[index].DefaultCellStyle.Font.Size=size

VB.NET中的常用方法的更多相关文章

  1. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  2. VB.NET中图像处理的一些技巧以及其和C#图像处理的差距。

    早期的时候我使用的开发工具是VB6,VB6做图像处理的速度在我的软件Imageshop中有所体现,还是算可以的.目前,我已经改用C#来研究图像算法,C#中有指针,做图像处理起来效率确实要高不少.VB. ...

  3. VB.NET中的除法运算符 与 C#中的除法运算符

    VB.NET中的除法运算符有两个:/(浮点除法).\(整数除法) C#中的除法运算符只有一个:/(除法) VB.NET中的除法运算符与C#中的除法运算符存在很大的差异,使用时注意区分. 关于VB.NE ...

  4. VB6中的引用传递 与 VB.NET中的引用传递的区别

    首先注意一点,在VB6中缺省参数传递的方式是:引用传递,而在VB.NET中缺省参数传递的方式是:值传递. 然后我们看下面VB6中的引用传递与VB.NET中的引用传递的对比. VB6中的引用传递 Pri ...

  5. VB.NET中使用Linq TO SQL添加数据后获得自增长列ID

    VB.NET中使用Linq TO SQL添加数据后获得自增长列ID: Dim tempOrdre As New Order With { .CustomerID = cmbCustomerName.S ...

  6. Java实战之02Hibernate-03Session中的常用方法

    九.Session中的常用方法 1.save方法 都是临时态————>持久态 2.persist方法 作用: 持久化临时态对象. 与save方法的区别: 开始了事务:persist和save没有 ...

  7. VB.NET中DataGridView控件

    VB.NET中对于表格数据的显示经常使用到DataGridView控件,其以丰富多样的数据表呈现形式被程序猿喜爱. 本人在做一个小系统中运用DataGridView控件的部分属性,这些功能的使用在使用 ...

  8. vb.net中存储过程的使用

    在机房收费系统过程中,试着使用了存储过程,离之前数据库的学习已经有些日子了.之前对于存储过程的了解也是听过而已,非常不清楚.因此,写这篇博客! 专业概念:存储过程是一个SQL语句和控制结构的集合,创建 ...

  9. javascript中数组常用方法总结

    原文:javascript中数组常用方法总结 在javascript的基础编程中,数组是我们最常遇到的,那么数组的一些常用方法也是我们必须要掌握的,下面我们总结一下数组中常用的方法. toString ...

随机推荐

  1. HDU 4738 Caocao's Bridges(割边)

    乍一看一个模板题,仔细一看还是模板题,但是三个坑.1,不是连通图,放0个.2 守卫为0,放1个. 3注意重边. #include<iostream> #include<cstdio& ...

  2. 多校 Cow Bowling

    题目链接:http://acm.hust.edu.cn/vjudge/contest/124435#problem/I 密码:acm Sample Input Sample Output 分析: #i ...

  3. Windows应用程序要点

    一个完整的Windows应用程序除了WinMain函数外,还包含用于处理用户动作和窗口消息的窗口函数.  Windows应用程序具有的一些特性: 消息驱动机制 图形设备接口(GDI) 基于资源的程序设 ...

  4. android 权限管理和签名 实现静默卸载

    为了实现静默卸载, 学了下android的安全体系,记录如下 最近在做个东西,巧合碰到了sharedUserId的问题,所以收集了一些资料,存存档备份. 安装在设备中的每一个apk文件,Android ...

  5. Installation error: INSTALL_FAILED_UID_CHANGED 的解决办法

    出现此问题的原因大多是apk冲突造成,解决的办法如下: 1.  Settings -> Applications, 卸载出现问题的apk,重新安装即可. 2. 如果apk无法卸载,则将apk相关 ...

  6. The Wall (medium)

    The Wall (medium) Heidi the Cow is aghast: cracks in the northern Wall? Zombies gathering outside, f ...

  7. 直接拿来用!最火的iOS开源项目(一)

    直接拿来用!最火的iOS开源项目(一) 发表于2013-06-05 10:17| 39373次阅读| 来源CSDN| 100 条评论| 作者唐小引 iOS开源项目GitHub移动开发最受欢迎的开源项目 ...

  8. logo集锦

    收集一个酷酷的技术公司的logo,一方面学习其中的美,另一方面打算用代码的画出这些logo算做致敬.感谢他们改变了我们的世界. 三星 苹果 戴尔 谷歌 IBM intel 惠普

  9. VS2015安装提示出现“安装包丢失或损坏”解决方法

    原因:microsoft root certificate authority 2010.microsoft root certificate authority 2011证书未安装,导致文件校验未通 ...

  10. hdu 5754 Life Winner Bo 博弈论

    对于king:我是套了一个表. 如果起点是P的话,则是后手赢,否则前手赢. 车:也是画图推出来的. 马:也是推出来的,情况如图咯. 对于后:比赛时竟然推错了.QAQ最后看了题解:是个威佐夫博奕.(2, ...