公共模块:
==============================================
Public Type structtype
id As Integer
name As String
End Type
==============================================
窗体1
==============================================
Private Sub Command1_Click()
Dim truct1 As structtype
truct1.id = 3
truct1.name = "lname"
'此处把 truct1 传递给form2的 testtru
form2.setinfo(truct1)
Form2.Show 0
End Sub
Public Type Employee '创建用户自定义的类型。
ID As Long '定义元素的数据类型。
Name As String * 20
Address As String * 30
Phone As Long
HireDate As Date
End Type
Public Function ShowName(Name_ID As Employee)
MsgBox Name_ID.Name & "," & Name_ID.ID
End Function
'=========================================================
下面窗体中
'=========================================================
Private Sub Command1_Click()
Dim Test As Employee
Test.Name = "张三"
Test.ID = 123456789
Call ShowName(Test)
End Sub
'=========================================================