VB 6.0 Type结构体赋值之后有没有清空的函数?
答案:3 悬赏:60 手机版
解决时间 2021-02-01 07:24
- 提问者网友:兔牙战士
- 2021-01-31 11:43
VB 6.0 Type结构体赋值之后有没有清空的函数?
最佳答案
- 五星知识达人网友:思契十里
- 2021-01-31 12:38
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
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
全部回答
- 1楼网友:不如潦草
- 2021-01-31 13:59
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
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
- 2楼网友:雪起风沙痕
- 2021-01-31 12:44
没有,可以定义一个空的结构变量,其它的结构变量要清空时可以把空结构变量赋值给它不就行了。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯