VB 6.0 Type结构体赋值之后有没有清空的函数?
发布网友
发布时间:2022-05-12 15:24
我来回答
共3个回答
热心网友
时间:2023-07-25 11:19
Option Explicit
Private Declare Sub RtlZeroMemory Lib "kernel32" ( _
ByVal Destination As Long, _
ByVal Length As Long)
Private Type Test
Id As Long
Age As Byte
Name As String
End Type
Public Sub Demo()
Dim t As Test
On Error GoTo Err_Demo
t.Id = 1
t.Age = 20
t.Name = "Cristin"
GoSub DisplayMsg
RtlZeroMemory VarPtr(t), LenB(t)
GoSub DisplayMsg
Err_Demo:
Exit Sub
DisplayMsg:
MsgBox "Id=" & t.Id & vbCrLf & _
"Age=" & t.Age & vbCrLf & _
"Name=" & t.Name
Return
End Sub
热心网友
时间:2023-07-25 11:19
没有,可以定义一个空的结构变量,其它的结构变量要清空时可以把空结构变量赋值给它不就行了。
热心网友
时间:2023-07-25 11:20
Private Type Test
a As Long
b As Integer
c As String
End Type
Private Sub ClearType(ByRef T As Test)
T.a = 0
T.b = 0
T.c = ""
End Sub
Private Sub Command1_Click()
Dim xx As Test
xx.a = 1
xx.b = 2
xx.c = "test"
ClearType xx
MsgBox xx.c
End Sub