As I was looking for a way of dynamically a sub I end up with the following solution
Now this litte app works and the subs are called dynamically, but when used in a bigger app it's giving me index (control(whichSub).SelectedIndex = 1) error, saying the index does not exists. A .Count however shows 2 items. I also wondered at what time a .Dispose is really disposed, because first I used a single combo box, but after a .Dispose I got an error the control was already defined when I tried to create it again.
So it works but doesn't work. Any concerns?
Scub
Sub App_Start
gotoSub("thisSub")
appClose
End Sub
Sub gotoSub (whichSub)
ErrorLabel(gotoError)
inError = false
AddComboBox("Form1", whichSub, 0, 0, 0, 0)
control(whichSub).Add(0)
control(whichSub).Add(1)
control(whichSub).SelectedIndex = 0
AddEvent(whichSub, SelectionChanged, whichSub)
'The event SelectionChanged will trigger the call
control(whichSub).SelectedIndex = 1
control(whichSub).Dispose
return
gotoError:
if inError then return
inError = true
if control(whichSub).Count = 2 then
Msgbox ("Error: Calling another gotoSub(" & chr(34) & whichSub & chr(34) & ") before the first one finished!", "thisSub", cMsgboxOK, cMsgBoxExclamation)
end if
return
End Sub
Sub thisSub (a,b)
Msgbox ("How did you get in thisSub?", "thisSub", cMsgboxOK)
gotoSub ("anotherSub")
End sub
Sub anotherSub (a,b)
Msgbox ("Another dynamically called sub.", "AnotherSub", cMsgboxOK)
'The next gotoSub causes an error
gotoSub ("thisSub")
End sub
Now this litte app works and the subs are called dynamically, but when used in a bigger app it's giving me index (control(whichSub).SelectedIndex = 1) error, saying the index does not exists. A .Count however shows 2 items. I also wondered at what time a .Dispose is really disposed, because first I used a single combo box, but after a .Dispose I got an error the control was already defined when I tried to create it again.
So it works but doesn't work. Any concerns?
Scub