I have been struggling with a problem passing a small array to be used in a form and I hope that somebody can help me. I cannot get the array into the form.
In the main module code I have an array containing information on a book reference:
Private Function PresentForm1(ByRef iID() As String, sBookRef() As String) As Boolean
Dim iCounter As Integer
For iCounter = LBound(iID) To UBound(iID)
Next Form1.ListBox1.Selected(0) = True
For iCounter = 0 To 2
MsgBox sBookRef(iCounter) ' This bit works fine
I need to use the sBookRef() array in a form that is called from the function so that a caption on the form changes depending on the item selected in the list box. Something along the lines of:
Private Sub ListBox1_Click()
Label1.Caption = sBookRef(ListBox1.ListIndex)
When I run the code I get a subscript out of range error.
I added the extra bit of code with the MsgBox to show that there are 3 valid values in the sBookRef() array within the lifetime of the original function. The problem I am having is in passing that array into the form so I can use it there.
I tried listing the array at the top of the module But it didn't seem to work either:
Public sBookRed() As String
Can anybody please help ?:(