Reputation: 63
I have a function that show the content of an array in excel sheet. The header of my function looks like this :
Public Sub afficher_signal(ByRef signal() As Integer, ByVal nb_ligne As Integer)
The probleme is that sometime I want to use it to display an Integer array and sometimes, its a double array i want to display. Is there a way to change the
ByRef signal() as Integer
by something that would accept any kind of array ?
Thank you very much !
Upvotes: 4
Views: 97
Reputation:
Replace
Public Sub afficher_signal(ByRef signal() As Integer, ByVal nb_ligne As Integer)
with
Public Sub afficher_signal(ByRef signal, ByVal nb_ligne As Integer)
or
Public Sub afficher_signal(ByRef signal as Variant, ByVal nb_ligne As Integer)
The below demonstrates a sample use of the afficher_signal
Public Sub Main()
Dim arr As Variant
arr = Array(1, "yo", 3, 10 Mod 2, 5.25)
afficher_signal arr, 0
afficher_signal2 arr, 0
End Sub
Public Sub afficher_signal(ByRef signal As Variant, ByVal nb_ligne As Integer)
Dim i As Long
For i = LBound(signal) To UBound(signal)
Debug.Print signal(i)
Next i
End Sub
Public Sub afficher_signal2(ByRef signal, ByVal nb_ligne As Integer)
Dim i As Long
For i = LBound(signal) To UBound(signal)
Debug.Print signal(i)
Next i
End Sub
Upvotes: 1