но я не могу использовать более 1 переменной в одной подпрограмме (part2)
Можно. Просто удалите (
и )
. Так становится
part2 Power_Origine, Power_Destination, Description_Destination, KnownUser_Destination
или используйте
Call part2(Power_Origine, Power_Destination, Description_Destination, KnownUser_Destination)
То же самое, что и выше. Вы все еще можете получить ошибку, потому что вы объявили Power_Origine As Integer, Power_Destination As Integer, Description_Destination As Integer, KnownUser_Destination As Integer
в part02
, но в part0
они Variants
. Объявите их как Integer
в part0
, и это будет работать:)
Sub part0()
Dim Power_Origine As Integer
Dim Description_Origine As Integer
Dim KnownUser_Origine As Integer
Dim Power_Destination As Integer
Dim Description_Destination As Integer
Dim KnownUser_Destination As Integer
Power_Origine = 1
Description_Origine = 2
KnownUser_Origine = 3
Power_Destination = 1
Description_Destination = 2
KnownUser_Destination = 3
part1 Power_Destination
part2 Power_Origine, Power_Destination, Description_Destination, KnownUser_Destination
End Sub
Sub part1(Power_Destination As Integer)
MsgBox Power_Destination
End Sub
Sub part2(P_Orig As Integer, P_Dest As Integer, D_Dest As Integer, K_Dest As Integer)
MsgBox "Hello " & P_Dest & D_Dest
End Sub
Вы также можете прочитать Передача переменных по ссылке и по значению