几周前,我得到了关于如何在此位置制作通用类模块的出色答案:类“ let”陷入无限循环
老实说,我仍然不太了解,因为我的vba知识100%是自学的,从这里开始,几年前C的一个学期还剩下一些通用编程逻辑。但是我认为我对此很有把握,因为这是一个很好的解释。我现在正在尝试将此方法与类中的字典一起使用,并且遇到了一些麻烦。
我的课程模块如下:
Option Explicit
Private Type categories
Temp As scripting.Dictionary
Humid As scripting.Dictionary
Wind As scripting.Dictionary
End Type
Private this As categories
Public Sub Initialize()
Set this.Temp = New scripting.Dictionary
Set this.Humid = New scripting.Dictionary
Set this.Wind = New scripting.Dictionary
End Sub
Public Property Get Temp(ByVal HourIndex As Long) As Double
Temp = this.Temp(HourIndex)
End Property
Public Property Let Temp(ByVal HourIndex As Long, ByVal Value As Double)
this.Temp(HourIndex) = Value
End Property
Public Property Get …Run Code Online (Sandbox Code Playgroud) 原谅代码中的任何愚蠢错误,因为这是我第一次尝试使用类,我找不到任何在线教程,这些教程非常简单地用于像我这样的傻瓜.我尽力按照https://msdn.microsoft.com/en-us/library/aa716315(v=vs.60).aspx上的MS指南,但我真的不明白我是什么无论如何,这很难解释我应该改变什么.
我正在尝试创建一个存储三个数据,两个整数和一个字符串的类.我把它放在一个名为的类模块中tdata:
Sub tdata()
Dim tnumber As Integer, tacct As Integer
Dim ttype As String
Public Property Get t_acct() As Integer 'don't forget the account number!
t_acct = tacct
End Property
Public Property Let t_acct(ByVal newval As Integer)
t_acct = newval
End Property
Public Property Get t_numb() As Integer 'T1, T2, or T3 as applicable
t_numb = tnumb
End Property
Public Property Let t_numb(ByVal newval As Integer)
t_numb = newval
End Property
Public Property …Run Code Online (Sandbox Code Playgroud)