Private Type SystemInfo CPU As Variant Memory As Long VideoColors As Integer Cost As Currency PurchaseDate As Variant End TypeDim MySystem AS SystemInfo MySystem.CPU = "486" If MySystem.PurchaseDate > #1/1/92# Then ....
'要试用本例请在窗体中加一个按钮,然后在代码窗体中粘贴如下代码'定义结构 Private Type Student Name As String Sex As String Age As Long End TypePrivate Sub Command1_Click() '声明变量为结构类型 Dim typS As Student
'给结构元素赋值 typS.Name = "王二小" typS.Sex = "男" typS.Age = 18 '引用结构元素的值 MsgBox typS.Name MsgBox typS.Sex MsgBox typS.Age End Sub
CPU As Variant
Memory As Long
VideoColors As Integer
Cost As Currency
PurchaseDate As Variant
End TypeDim MySystem AS SystemInfo
MySystem.CPU = "486"
If MySystem.PurchaseDate > #1/1/92# Then ....
Private Type Student
Name As String
Sex As String
Age As Long
End TypePrivate Sub Command1_Click()
'声明变量为结构类型
Dim typS As Student
'给结构元素赋值
typS.Name = "王二小"
typS.Sex = "男"
typS.Age = 18 '引用结构元素的值
MsgBox typS.Name
MsgBox typS.Sex
MsgBox typS.Age
End Sub