这标题话有点ao口,还是举例吧'在一个模块中定义了两个自定义类型:
Public Type At
a As Integer
b As Integer
End TypePublic Type Bt
a As Integer
b As Integer
End Type
'另一个地方用到了:
Private Sub Form_Load()
Dim x '----------------此处, x 要 As 什么才下面的代码才不会出错呢?
Dim a As At
Dim b As Bt
x = a
x = b
End Sub
Public Type At
a As Integer
b As Integer
End TypePublic Type Bt
a As Integer
b As Integer
End Type
'另一个地方用到了:
Private Sub Form_Load()
Dim x '----------------此处, x 要 As 什么才下面的代码才不会出错呢?
Dim a As At
Dim b As Bt
x = a
x = b
End Sub
解决方案 »
- 词句如何解释 谢 vb.net中类!
- vb的日期控件问题
- 讨论"VB打印"完美解决方案(来者有分!!!)
- treeview怎样设置才可以左右移动?
- 如何通过API函数来操作MSFlexGrid 控件!(3个月没有人解决)
- 在VB中如何实现在MAIN函数中接受运行时,外界传入的参数?具体如何实现?
- 以下代码打开dbf文件,但获得数据中有中文汉字的都是乱码!什么问题?盼大侠解救!在线等阿!
- 如何合并MSFlexGrid的第一行和第二行的前两列四个单元格?
- 高手们请进!如何在程序中修改一个已存在的文件的扩展名.
- 串行端口共分几条线?各自的作用是什么?
- 求助下关于microsoft windows common controls 5.0
- 高手如何计算角度.
类里面的代码
类名 Cls
public a As Integer
public b As Integer引用Private Sub Form_Load()
Dim x as Object
Dim a As New Cls
Dim b As New Cls
set x = a
set x = b
End Sub
但我是懒人~~而且一定要数组~
dim x as Variant
'类里面的代码,类名Class1Option ExplicitPrivate m_Arr(100) As String
Public Property Get Arr(ByVal Index As Integer) As String
Arr = m_Arr(Index)
End PropertyPublic Property Let Arr(ByVal Index As Integer, ByVal vNewValue As String)
m_Arr(Index) = vNewValue
End Property
'窗体中的代码
Option ExplicitPrivate Sub Command1_Click()
Dim A1 As New Class1
A1.Arr(1) = "12"
MsgBox A1.Arr(1)
End Sub
不过对 UDT(User Define Type) 要求是具有 UUID 的,意思就是:
·要么 Public Type 声明在 ActiveX Dll/Exe/Control 工程的 Public Class/Control 中;
·要么将结构声明在 tlb 中。《高级 Visual Basic 编程》(Advance Visual Basic) 中说得很明白。可以在 CSDN 得资源下载中找到该书。
等把这本书修炼完了,我也应该是高手了,哼哼哼哼~~