excel - 使用变量来引用类模块 VBA
问题描述
我正在学习 VBA,但在使用变量引用类模块时遇到问题。所以,我有一个具有此功能的模块 MAIN:
Public sub correr_lista ()
For i = LBound(lista) To UBound(lista) - 1
Call verifica (lista (i).time, lista_ficheiros(i + 1).time, lista (i).setor)
next i
End public
在同一个模块中我有这个功能
Public Sub verifica (time1 As Date, time2 As Date, V_setor As String)
'Percorre a lista para ver o tipo de torneira e a sua velocidade
For a = LBound(listaon) To UBound(listaon)
If (listaon(a).setor = V_setor) Then
' Pergunta à torneira porta qual a sua velocidade
aux_velocidade(a) = V_setor.getvelocidade(listaon(a).porta)
next a
End sub
我有类模块 Setor
Public Function getvelocidade(porta As String)
Dim velocidade As Integer
For a = LBound(listaSetor) To UBound(listaSetor)
velocidade = listaSetor(a).get_velocidade(porta)
Next i
getvelocidade = velocidade
end function
listSector 列表定义为:
Dim listaSetor () As Object
我们在水龙头类模块
Public Function get_velocidade(n_porta As String)
Dim aux As Double
For i = LBound(porta) To UBound(porta)
aux = porta(i).velocidade
Next i
get_velocidade = aux
End Function
门定义为:
Dim porta(1 To 3) As tipo
Public Type tipo
porta As String
nome As String
velocidade As Double
tipo As String
End Type
出现的错误是该行的方法验证中的无效限定符:
aux_velocidade(a) = V_setor.getvelocidade(listaon(a).porta)
当错误出现时,它会在变量 V_setor 下划线
我该如何解决这个问题?
解决方案
推荐阅读
- postgresql - 使用 Sqitch 迁移的数据库播种
- azure - Azure API 管理订阅的自定义 API 密钥
- c# - 如何读取 .TDAT 文件?
- macos - WxWidgets Build on OSX 10.15.4 错误(尝试不同的 SDK)
- javascript - 如何在 React 的主组件中的 onClick 事件中显示来自子组件的相应元素?
- nearprotocol - 近协议如何区分合约?
- .net - Oracle做参数可以防止SQL注入吗?
- java - Java GRPC ServerBuilder 与 NettyServerBuilder
- sql - 为 2000 年 12 月租用的汽车选择品牌和型号?
- assembly - 为什么buf的地址是0x12而不是10?