在VB.NET中定义结构体就用Structure关键字,那么该如何使用Structure定义VB结构体呢,请看如下代码,成员属性要用Dim来修饰:
Public Structure INITTBL Dim speed As Long Dim length As Long Dim parity As Long Dim sbit As Long Dim ptout As Long Dim ctout As Long Dim stopkey1 As Long Dim stopkey2 As Long Dim cretry As Long End Structure
如何使用VB.NET结构体呢?只要在需要使用的地方如下定义并初始化即可,如下:
Dim tab As INITTBL tab.speed = 4 tab.length = 0 tab.parity = 0 tab.sbit = 1 tab.ptout = 100 tab.ctout = 1000 tab.stopkey1 = 0 tab.stopkey2 = 0 tab.cretry = 99
VB结构体很常用,所以必须得知道怎么使用它。