PDA

View Full Version : ByRef Array Button Click



LePig
02-05-2019, 07:56 AM
Hi,

I am trying to pass an array generated on one button click to a subroutine button click. For example



Private Sub Retrieve_Attendance_click(ByRef LArrayDatesOfPay() As String)Dim todays_date_from As Variant
Dim todays_date_to As Variant
Dim rowNumSubmit As Range
'Dim LArrayDatesOfPay() As String
Dim txtB1 As Control
Dim myrow_10() As Integer
'Main.Hide
'Submit_Wages.Retrieve_Attendance.Visible = False
Call PopulateArrayEmployed
todays_date_from = Me.Date_Picker_Wages_Start_Date.Value
todays_date_to = Me.Date_Picker_Wages_End_Date.Value
x = 1


For Each rowNumSubmit In ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows
ReDim Preserve myrow_10(x)
myrow_10(x) = rowNumSubmit.row - 1
If ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows(myrow_10(x)).Value >= todays_date_from _
And ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows(myrow_10(x)).Value <= todays_date_to Then

ReDim Preserve LArrayDatesOfPay(x)
LArrayDatesOfPay(x) = ThisWorkbook.Worksheets("Input Take Sheet").Range("Input_take_table[Date]").Rows(myrow_10(x)).Value


x = x + 1

End If

Next

and then



Private Sub Wages_Submit_Click()Dim LArrayDatesOfPay() As Date


Call Retrieve_Attendance_click(LArrayDatesOfPay)
MsgBox UBound(LArrayDatesOfPay)


End Sub

But it keeps coming up with a compile error Procedure declaration does not match description of event or procedure having the same name error.

Any help would be greatly appreciated.

Kind Regards

Fluff
02-05-2019, 08:35 AM
Cross posted on multiple sites

please read this http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_new_faq_item3

Paul_Hossler
02-05-2019, 09:18 AM
+1 on cross posting

Click events have a 'fixed' definition and you can't just change them to pass a parameter

I'd save it in a Public variable in one sub and then use it in the second