If I understand you correctly, just create your control array, I've tested it with Labels and it works. Double click on any one of them and it will automatically create a blank sub for you:
Private Sub Label1_Click(Index As Integer)
End Sub
The variable called index that is being passed to the sub contains the index of the control. You can use this in any way you want. Try putting: MsgBox (Index) inside this sub and running it, you will see your index number!!
To pass it to a different form you can add a module to your project: Project -> Add Module, and add the following line to it:
Public globalindex As Integer
Add the following code to Form1:
Private Sub Label2_Click(Index As Integer)
globalindex = Index
Form1.Hide
Form2.Show
End Sub
You can then use this variable in Form2:
Private Sub Form_Load()
FileName = "C:/" & globalindex & ".csv"
Open FileName For Output As #1
Print #1, "this Is a test"
Close #1
End Sub
Enter your message below
Sign in or Join us (it's free).