定义了一个自定义变量,里面有多个属性。请问有什么方法清空所有属性的值。是全局变量。Public Type 单据
ID As Long
单据号 As String
单据类别 As Integer
操作员 As String
员工工号 As Integer
员工姓名 As String
病人姓名 As String
病人年龄 As Integer
病人性别 As String
药品信息 As String
End TypeVB全局变量
ID As Long
单据号 As String
单据类别 As Integer
操作员 As String
员工工号 As Integer
员工姓名 As String
病人姓名 As String
病人年龄 As Integer
病人性别 As String
药品信息 As String
End TypeVB全局变量
'直接置空,VB6.0不支持. 以下采用变相的方式置空.
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypeDim mRect As RECT '设置为空的Type
Dim uRect As RECTPrivate Sub Command1_Click()
uRect.Left = 200
uRect.Right = 300
uRect.Top = 400
uRect.Bottom = 500
CopyMemory uRect, mRect, Len(mRect) '将空的Type内容复制至要置空的Type
MsgBox uRect.Left
MsgBox uRect.Right
MsgBox uRect.Top
MsgBox uRect.Bottom
End Sub
Dim tEmpty As 单据
t = tEmpty
End Sub
public 单据1 AS 单据窗体中:
Private Sub Command1_Click()
Dim 空单据 As 单据
单据1=空单据
End Sub
public 单据1 AS 单据
public 空单据 AS 单据sub 清空单据
单据1=空单据
end sub窗体中:
Private Sub Command1_Click()单据1=空单据
End SubPrivate Sub Command2_Click()
清空单据
End Sub用Command1_Click()
或Command2_Click()
这2种方式都可以