VB程序员博客
先定义了一个类模块Lead
Public Conductor_Earth As Boolean '判别是导线还是地线
Public Name As String '导地线名称
'—-电线的相关参数———
Dim A As Double ' 电线的总截面积
Dim d As Double '电线的直径
Dim M As Double '电线质量
Dim E As Double '弹性系数
Dim af As Double '温度伸长系数
Dim tp As Double '拉断力
Dim F As Double '使用安全系数
Dim AV As Double '平均运行张力占拉断力的百分比
Dim n As Integer '导线分裂数
Dim Fm As Double '最大使用张力
Dim Fa As Double '平均运行应力
'—–比载—————–
Dim g1 As Double '自重力荷载
Dim g2 As Double '冰重力荷载
Dim g3 As Double '自重力加冰重力荷载
Dim g4 As Double '无冰时的风荷载
Dim g5 As Double '覆冰时的风荷载
Dim g6 As Double '无冰时的综合荷载
Dim g7 As Double '覆冰时的综合荷载
Dim wind_a As Double '风压系数
Dim Inequal_wind_a As Double '风压不均匀系数
Dim Figure_a As Double '体形系数
Dim ave_height As Double '电线平均高度
Dim Ge As Double '重力加速度
Dim Ice_thick As Double '定义冰厚
'–重力加速度
Public Property Get Gravity() As Variant
Gravity = Ge
End Property
Public Property Let Gravity(ByVal vNewGravity As Variant)
Ge = vNewGravity
End Property
'–冰厚
Public Property Get IceThick() As Variant
IceThick = Ice_thick
End Property
Public Property Let IceThick(ByVal vNewIceThick As Variant)
Ice_thick = vNewIceThick
End Property
'–截面积属性
Public Property Get SectionaArea() As Variant
SectionArea = A
End Property
Public Property Let SectionaArea(ByVal vNewSectionArea As Variant)
A = vNewSectionArea
End Property
'–直径属性
Public Property Get Diameter() As Variant
Diameter = d
End Property
Public Property Let Diameter(ByVal vNewDiameter As Variant)
d = vNewDiameter
End Property
'–单位质量属性
Public Property Get Mass() As Variant
Mass = M
End Property
Public Property Let Mass(ByVal vNewMass As Variant)
M = vNewMass
End Property
'–弹性系数属性
Public Property Get ElasticCoefficient() As Variant
ElasticCoefficient = E
End Property
Public Property Let ElasticCoefficient(ByVal vNewElasticCoefficient As Variant)
E = vNewElasticCoefficient
End Property
'–温度伸长系数
Public Property Get TemperatureElongate() As Variant
TemperatureElongate = af
End Property
Public Property Let TemperatureElongate(ByVal vNewTemperatureElongate As Variant)
af = vNewTemperatureElongate
End Property
(下面还有代码若干,省略)
然后在另外一个类模块OperationMode中,其中一个属性就是Lead变量。
Public Conductor_Earth As Boolean '判别是导线还是地线
Public Name As String '工况名称
Public Mark As String '用于工况排序
Public Jump As Boolean ' 是否被隔越
Public Lcrl As Double '临界档距下限
Public Lcrh As Double '临界档距上限
Dim te As Double ' 传递参数
Dim v As Double
Dim th As Double
Dim tp As Double
Dim tr As Double
Dim L As Lead
Dim ro As Double
'–线模块参量
Public Property Get Line() As Lead
Line = L
End Property
Public Property Let Line(ByVal vNewLine As Lead)
Set L = New Lead
L = vNewLine'——>这里报错!
End Property
(下面还有代码若干,省略)
调试的时候,报错:对象不支持这个属性或方法(错误 438)
在类模块中如何定义和使用自己做的类模块呢?
非常感谢了!
Set objHandleMenu = Nothing →Set objAA = Nothing
up
是放在这里吗?
Public Property Let Line(ByVal vNewLine As Lead)
Set L = CreateObject(Lead)
L = vNewLine
End Property
但是还是不对啊?
楼上能不能说具体一点到底是哪里有问题啊?
非常非常感谢!
这样还是有问题。
不明白究竟是怎么回事。可否再指点一下,非常感谢了!
还是这个在VB中没有办法实现啊?
要是这个都没有办法实现,那企不是太痛苦了啊?
lead 是一个类对象,要用set
Public Property Let Line(ByVal vNewLine As Lead)
'Set L = CreateObject(Lead)
set L = vNewLine
End Property
设置类变量要用set
Public Property Let Line(ByVal vNewLine As Lead)
Set L = New Lead
' L = vNewLine'——>这里报错!
'改成
Set L=vNewLine
End Property
啊,通过了!非常非常感谢大家!
标签: 模块