Hello dear forum users,
Im making a application where i have couple of listboxes on a form. The problem is that my code is repeating too much so im trying to avoid this repetitive code.
So i decided to make a function with the form as an input and an output of an selected index.
so im running the function like this
The problem is that when i pass a name of a form it pass only bounded value. I even tried to pass a form as an object but wihout luck.
Can anyone provide me a hint how to pass an form ?
Thanks in advance.
Im making a application where i have couple of listboxes on a form. The problem is that my code is repeating too much so im trying to avoid this repetitive code.
Code:
for i = 1 to listbox.ListCount......
boilerplate code to find selected index
So i decided to make a function with the form as an input and an output of an selected index.
Code:
Private Function selectedIndex(ByVal lstbox As MSForms.ListBox) As Integer
for i = 1 to lstbox.ListCount......
so im running the function like this
Code:
idx = selectedIndex(listbox)
The problem is that when i pass a name of a form it pass only bounded value. I even tried to pass a form as an object but wihout luck.
Can anyone provide me a hint how to pass an form ?
Thanks in advance.