|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cannot pass a control array ?Why does it not compile ? Am I missing something ? I am sure cmdPick1 was
set up as an array in the form. TIA Private Sub XXX Call QuickPick(cmdPick1) End Sub ---------------------------------------- Private Sub QuickPick(cmdx() As CommandButton) ' End Sub
Show quote
Hide quote
"Phil H" <phung1***@hotmail.com> wrote in message Since both Subs are Private, they must be in the same module....so why are news:%232%23w2iRlJHA.1184@TK2MSFTNGP04.phx.gbl... > Why does it not compile ? Am I missing something ? I am sure cmdPick1 was > set up as an array in the form. TIA > > > Private Sub XXX > Call QuickPick(cmdPick1) > End Sub > ---------------------------------------- > > Private Sub QuickPick(cmdx() As CommandButton) > ' > End Sub you trying to pass it at all? In any case, trying using As Object or As Variant as the parameter type. -- Mike The real codes are in seperate module. I just put them in the same module in
my post to make it easier to read. I tried your suggestion to no avail. I remember someone asked this question before. Maybe someone would know the answer. Thanks anyway. Show quoteHide quote "MikeD" <nob***@nowhere.edu> wrote in message news:O7bFNJSlJHA.2384@TK2MSFTNGP04.phx.gbl... > > "Phil H" <phung1***@hotmail.com> wrote in message > news:%232%23w2iRlJHA.1184@TK2MSFTNGP04.phx.gbl... >> Why does it not compile ? Am I missing something ? I am sure cmdPick1 was >> set up as an array in the form. TIA >> >> >> Private Sub XXX >> Call QuickPick(cmdPick1) >> End Sub >> ---------------------------------------- >> >> Private Sub QuickPick(cmdx() As CommandButton) >> ' >> End Sub > > > Since both Subs are Private, they must be in the same module....so why are > you trying to pass it at all? > > In any case, trying using As Object or As Variant as the parameter type. > > -- > Mike > "Phil H" <phung1***@hotmail.com> wrote... This works, Command2 is a control array,> I tried your suggestion to no avail. I remember someone asked this > question before. Maybe someone would know the answer. > > Thanks anyway. Private Sub Command1_Click() Call QuickPick(Command2) End Sub Private Sub QuickPick(cmdx As Object) Debug.Print cmdx(0).Caption End Sub Yeah, that works. Syntax is slighty different from passing an array. In my
real code, i am also passing a string array and I have to pass it with (). That's confusing. Thanks Show quoteHide quote "David Youngblood" <d**@flash.net> wrote in message news:uI3S4LTlJHA.2064@TK2MSFTNGP05.phx.gbl... > "Phil H" <phung1***@hotmail.com> wrote... >> I tried your suggestion to no avail. I remember someone asked this >> question before. Maybe someone would know the answer. >> >> Thanks anyway. > > This works, Command2 is a control array, > Private Sub Command1_Click() > Call QuickPick(Command2) > End Sub > > Private Sub QuickPick(cmdx As Object) > Debug.Print cmdx(0).Caption > End Sub > > > Hi Phil,
Control arrays are not really arrays. They are enumerable though, so you can use a For Each loop with them. They are more like a collection class than an array. Show quoteHide quote "Phil H" <phung1***@hotmail.com> wrote in message news:OiLRMVTlJHA.5980@TK2MSFTNGP06.phx.gbl... > Yeah, that works. Syntax is slighty different from passing an array. In my > real code, i am also passing a string array and I have to pass it with (). > That's confusing. > > Thanks > > > "David Youngblood" <d**@flash.net> wrote in message > news:uI3S4LTlJHA.2064@TK2MSFTNGP05.phx.gbl... >> "Phil H" <phung1***@hotmail.com> wrote... >>> I tried your suggestion to no avail. I remember someone asked this >>> question before. Maybe someone would know the answer. >>> >>> Thanks anyway. >> >> This works, Command2 is a control array, >> Private Sub Command1_Click() >> Call QuickPick(Command2) >> End Sub >> >> Private Sub QuickPick(cmdx As Object) >> Debug.Print cmdx(0).Caption >> End Sub >> >> >> > >
Show quote
Hide quote
"Phil H" <phung1***@hotmail.com> wrote in message Assuming you are passing the cmdPick1 second item of the arrary, wouldn't that be:news:%232%23w2iRlJHA.1184@TK2MSFTNGP04.phx.gbl... > Why does it not compile ? Am I missing something ? I am sure cmdPick1 was set up as an > array in the form. TIA > > > Private Sub XXX > Call QuickPick(cmdPick1) > End Sub > ---------------------------------------- > > Private Sub QuickPick(cmdx() As CommandButton) > ' > End Sub > > > Private Sub XXX Galen> Call QuickPick(cmdPick1(1)) > End Sub
Show quote
Hide quote
"Phil H" <phung1***@hotmail.com> escribió en el mensaje de noticias Debug.Print IsArray(cmdPick1), TypeName(cmdPick1)news:%232%23w2iRlJHA.1184@TK2MSFTNGP04.phx.gbl... > Why does it not compile ? Am I missing something ? I am sure cmdPick1 was > set up as an array in the form. TIA > > > Private Sub XXX > Call QuickPick(cmdPick1) > End Sub > ---------------------------------------- > > Private Sub QuickPick(cmdx() As CommandButton) > ' > End Sub Your code doesn't compile because a control array is not an array, but an Object, so your 'Sub' should be "QuickPick(cmdx As Object)". -- Regards - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ( ! ) http://groups.google.com/group/microsoft.public.vb.general.discussion ( i ) http://www.microsoft.com/communities/conduct/default.mspx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Passing as Object did not compile either.
<Vinchenzo vin? <Vinç@newsgroup.nospam>> wrote in message Show quoteHide quote news:eY4koBTlJHA.2460@TK2MSFTNGP06.phx.gbl... > "Phil H" <phung1***@hotmail.com> escribi?en el mensaje de noticias > news:%232%23w2iRlJHA.1184@TK2MSFTNGP04.phx.gbl... >> Why does it not compile ? Am I missing something ? I am sure cmdPick1 was >> set up as an array in the form. TIA >> >> >> Private Sub XXX >> Call QuickPick(cmdPick1) >> End Sub >> ---------------------------------------- >> >> Private Sub QuickPick(cmdx() As CommandButton) >> ' >> End Sub > > > Debug.Print IsArray(cmdPick1), TypeName(cmdPick1) > Your code doesn't compile because a control array is not an array, but > an Object, so your 'Sub' should be "QuickPick(cmdx As Object)". > > > -- > Regards > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > ( ! ) > http://groups.google.com/group/microsoft.public.vb.general.discussion > ( i ) http://www.microsoft.com/communities/conduct/default.mspx > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
optional args to a class.Init method
Anyway to move Image control at runtime Dim WithEvents * As HTMLDocument with an Iframe - access denied!? Recommended IDE for the PocketPC Automatic determine .Rows in MSHFLexgrid convert Unicode string Remove empty elements from end of array Use ColumnClick and Click Event in MSHFLexGrid asp RGB to CIELAB (or simply lab) color conversion |
|||||||||||||||||||||||