can a control array be passed to a function 
Author Message
 can a control array be passed to a function

I have the following code:

private sub form_load()
    call somefunction(check1)
end sub

private sub somefunction(SomeControl as Control)
    code.....
end sub

If I use a standard control it passes if fine however if I use a control
array I keep getting the type mismatch error.  How can I do this?



Tue, 28 Dec 2004 06:21:07 GMT  
 can a control array be passed to a function
Sure.. if you drop an array of textboxes and a command button on a form,
you'll see one way of doing it.. The code below just returns a string that
contains all of the text from the textbox array that you pass to it.
'==========
Option Explicit

Private Sub Command1_Click()
   Debug.Print AllText(Text1)
End Sub

Private Function AllText(TBArray As Object)
   Dim oTB As TextBox
   For Each oTB In TBArray
      AllText = AllText & oTB.Text & vbCrLf
   Next
End Function
'==========

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm

Quote:

> I have the following code:

> private sub form_load()
>     call somefunction(check1)
> end sub

> private sub somefunction(SomeControl as Control)
>     code.....
> end sub

> If I use a standard control it passes if fine however if I use a
> control array I keep getting the type mismatch error.  How can I do
> this?



Tue, 28 Dec 2004 09:51:59 GMT  
 can a control array be passed to a function
Thank you very much that worked like a charm.

It's amazing how much attention to detail you have to put into writing a
computer program.  You'd think with all the things computers can do they
would be a little more tuned to common sense.


Quote:
> Sure.. if you drop an array of textboxes and a command button on a form,
> you'll see one way of doing it.. The code below just returns a string that
> contains all of the text from the textbox array that you pass to it.
> '==========
> Option Explicit

> Private Sub Command1_Click()
>    Debug.Print AllText(Text1)
> End Sub

> Private Function AllText(TBArray As Object)
>    Dim oTB As TextBox
>    For Each oTB In TBArray
>       AllText = AllText & oTB.Text & vbCrLf
>    Next
> End Function
> '==========

> --
> Ken Halter - MS-MVP-VB - Please keep it in the groups..
> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


> > I have the following code:

> > private sub form_load()
> >     call somefunction(check1)
> > end sub

> > private sub somefunction(SomeControl as Control)
> >     code.....
> > end sub

> > If I use a standard control it passes if fine however if I use a
> > control array I keep getting the type mismatch error.  How can I do
> > this?



Tue, 28 Dec 2004 11:07:59 GMT  
 can a control array be passed to a function
Tell me about it! I remember getting my first computer... couldn't wait to
get home, plug it in and start asking it questions <g>.. All I got was a
command prompt that kept flashing "Ok" all day.. It answered all of my
questions though... only thing was, the answer was always the same...
"Syntax Error".. I guess that's the answer to all of mans questions
(according to my first days on a computer anyway <g>)

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm

Quote:

> Thank you very much that worked like a charm.

> It's amazing how much attention to detail you have to put into
> writing a computer program.  You'd think with all the things
> computers can do they would be a little more tuned to common sense.



>> Sure.. if you drop an array of textboxes and a command button on a
>> form, you'll see one way of doing it.. The code below just returns a
>> string that contains all of the text from the textbox array that you
>> pass to it. '==========
>> Option Explicit

>> Private Sub Command1_Click()
>>    Debug.Print AllText(Text1)
>> End Sub

>> Private Function AllText(TBArray As Object)
>>    Dim oTB As TextBox
>>    For Each oTB In TBArray
>>       AllText = AllText & oTB.Text & vbCrLf
>>    Next
>> End Function
>> '==========

>> --
>> Ken Halter - MS-MVP-VB - Please keep it in the groups..
>> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


>>> I have the following code:

>>> private sub form_load()
>>>     call somefunction(check1)
>>> end sub

>>> private sub somefunction(SomeControl as Control)
>>>     code.....
>>> end sub

>>> If I use a standard control it passes if fine however if I use a
>>> control array I keep getting the type mismatch error.  How can I do
>>> this?



Tue, 28 Dec 2004 12:46:43 GMT  
 can a control array be passed to a function
Gee my first dos computer said "Bad command or file name"!  took all day to
work out that it would do nothing at all without the purchase of some
software.

The TRASH80 that preceeded it at least didn't claim to actually do anything
useful, apart from play games using cartridges.   That CLOAD just never
worked properly for me.  Always had to load everything 2 or 3 times.

Well I  tell a lie.  Edlin would let me write a letter if I had all day.

Matt


Quote:
> Tell me about it! I remember getting my first computer... couldn't wait to
> get home, plug it in and start asking it questions <g>.. All I got was a
> command prompt that kept flashing "Ok" all day.. It answered all of my
> questions though... only thing was, the answer was always the same...
> "Syntax Error".. I guess that's the answer to all of mans questions
> (according to my first days on a computer anyway <g>)

> --
> Ken Halter - MS-MVP-VB - Please keep it in the groups..
> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


> > Thank you very much that worked like a charm.

> > It's amazing how much attention to detail you have to put into
> > writing a computer program.  You'd think with all the things
> > computers can do they would be a little more tuned to common sense.



> >> Sure.. if you drop an array of textboxes and a command button on a
> >> form, you'll see one way of doing it.. The code below just returns a
> >> string that contains all of the text from the textbox array that you
> >> pass to it. '==========
> >> Option Explicit

> >> Private Sub Command1_Click()
> >>    Debug.Print AllText(Text1)
> >> End Sub

> >> Private Function AllText(TBArray As Object)
> >>    Dim oTB As TextBox
> >>    For Each oTB In TBArray
> >>       AllText = AllText & oTB.Text & vbCrLf
> >>    Next
> >> End Function
> >> '==========

> >> --
> >> Ken Halter - MS-MVP-VB - Please keep it in the groups..
> >> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


> >>> I have the following code:

> >>> private sub form_load()
> >>>     call somefunction(check1)
> >>> end sub

> >>> private sub somefunction(SomeControl as Control)
> >>>     code.....
> >>> end sub

> >>> If I use a standard control it passes if fine however if I use a
> >>> control array I keep getting the type mismatch error.  How can I do
> >>> this?



Tue, 28 Dec 2004 22:17:25 GMT  
 can a control array be passed to a function
That TRASH80 computer you're talking about... wouldn't be a Color Computer
would it? I had several (1 through 3... from 4k to 512k)... they were much
better computers than people gave them credit for.. Heck.. the CPU was a
Motorola 6809e.. which at the time was better/faster (despite the lower
bandwidth clock) than an IBM PC's 8086. The 6809 was very programmer
friendly.. you could load an assembly language program into ram starting at
*any* location and.. since it had full support for indirect / relative
addressing, it would run just fine. The Basic on a ROM chip was great too!..
Had hooks everywhere to enable you to add your own words to the language...
or change the way a certain function worked (eprom burner to make these
changes permanent)... anything you want. Plus.. since it was on a ROM chip,
it was ready to go as soon as you powered up.. No "boot" time at all. The
CoCo (always hated that name) 3 was upgradable to 512k... but since you
could only use 32k at a time, you had to swap 4k blocks in and out at the
right time.. sounds ugly.. but it was electronic memory block swapping (not
moving ram from here to there) so it was quite fast.

Those cartridge based games were a joke!. But I had the "MultiPak Interface"
which allowed 4 such cartridges.. One for my floppy drive controller, one
for my "Disto Ramdrive" <g>, one for my Eprom burner and one for what ever
game I had laying around. The number one cause of people hating Tandy
computers in those days was (imo)... for parts/software and support, you had
to go into Radio Shack and ask some battery salesman technical questions
about the computer.. which... not one of those guys were ready for. At least
now... since they sell big name brand computers there, you can get support
from the manufacturer.

I still have a notebook that contains the source code for the Monopoly game
I wrote on that computer... submitted it to Rainbow Magazine (which was the
VBPJ of its day)... but alas, it was too huge to print in one issue so I was
rejected.

I haven't been to RS in a *long* time... maybe I'll drop in and... well..
buy a battery... just for old times sake <g>

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm

Quote:

> Gee my first dos computer said "Bad command or file name"!  took all
> day to work out that it would do nothing at all without the purchase
> of some software.

> The TRASH80 that preceeded it at least didn't claim to actually do
> anything useful, apart from play games using cartridges.   That CLOAD
> just never worked properly for me.  Always had to load everything 2
> or 3 times.

> Well I  tell a lie.  Edlin would let me write a letter if I had all
> day.

> Matt



Wed, 29 Dec 2004 10:27:21 GMT  
 can a control array be passed to a function
Ken it was a TRS80 with 8 colour display and many an enjoyable day was
passed with this machine.  It  had a 16k memory and I cut my teeth so to
speak on Basic from the ROM.   I never really did anything great or
technical with it, wrote card games and the like but it was the source of my
passion for the Basic Language.

When I went out and had to learn SAS  the thing that amazed me at the outset
was how similar the syntax was.  Similar enough to make the transition  very
easy,  3 hours of on the job tuition and I was called a Liaison Programmer.
The hard part of that was learning JCL and the JES entry system.  Then came
all sorts of little wonders of the MVS mainframe OS.  But I am back to my
first love Basic and the PC.

Matt


Quote:
> That TRASH80 computer you're talking about... wouldn't be a Color Computer
> would it? I had several (1 through 3... from 4k to 512k)... they were much
> better computers than people gave them credit for.. Heck.. the CPU was a
> Motorola 6809e.. which at the time was better/faster (despite the lower
> bandwidth clock) than an IBM PC's 8086. The 6809 was very programmer
> friendly.. you could load an assembly language program into ram starting
at
> *any* location and.. since it had full support for indirect / relative
> addressing, it would run just fine. The Basic on a ROM chip was great
too!..
> Had hooks everywhere to enable you to add your own words to the
language...
> or change the way a certain function worked (eprom burner to make these
> changes permanent)... anything you want. Plus.. since it was on a ROM
chip,
> it was ready to go as soon as you powered up.. No "boot" time at all. The
> CoCo (always hated that name) 3 was upgradable to 512k... but since you
> could only use 32k at a time, you had to swap 4k blocks in and out at the
> right time.. sounds ugly.. but it was electronic memory block swapping
(not
> moving ram from here to there) so it was quite fast.

> Those cartridge based games were a joke!. But I had the "MultiPak
Interface"
> which allowed 4 such cartridges.. One for my floppy drive controller, one
> for my "Disto Ramdrive" <g>, one for my Eprom burner and one for what ever
> game I had laying around. The number one cause of people hating Tandy
> computers in those days was (imo)... for parts/software and support, you
had
> to go into Radio Shack and ask some battery salesman technical questions
> about the computer.. which... not one of those guys were ready for. At
least
> now... since they sell big name brand computers there, you can get support
> from the manufacturer.

> I still have a notebook that contains the source code for the Monopoly
game
> I wrote on that computer... submitted it to Rainbow Magazine (which was
the
> VBPJ of its day)... but alas, it was too huge to print in one issue so I
was
> rejected.

> I haven't been to RS in a *long* time... maybe I'll drop in and... well..
> buy a battery... just for old times sake <g>

> --
> Ken Halter - MS-MVP-VB - Please keep it in the groups..
> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


> > Gee my first dos computer said "Bad command or file name"!  took all
> > day to work out that it would do nothing at all without the purchase
> > of some software.

> > The TRASH80 that preceeded it at least didn't claim to actually do
> > anything useful, apart from play games using cartridges.   That CLOAD
> > just never worked properly for me.  Always had to load everything 2
> > or 3 times.

> > Well I  tell a lie.  Edlin would let me write a letter if I had all
> > day.

> > Matt



Wed, 29 Dec 2004 16:24:13 GMT  
 can a control array be passed to a function
Wow, my simple little comment invoked a lot of reminiscing.  I was also
shocked to learn that both of you (Ken Halter & Unicorn) have a little bit
of age on me or so it seems.  I am coming up on the big three-zero and even
though that's relatively young while trolling these newsgroups you start to
get the feeling that the big three-zero seem so ancient.  Lot of young kids
in here now a days.


Quote:
> Thank you very much that worked like a charm.

> It's amazing how much attention to detail you have to put into writing a
> computer program.  You'd think with all the things computers can do they
> would be a little more tuned to common sense.



> > Sure.. if you drop an array of textboxes and a command button on a form,
> > you'll see one way of doing it.. The code below just returns a string
that
> > contains all of the text from the textbox array that you pass to it.
> > '==========
> > Option Explicit

> > Private Sub Command1_Click()
> >    Debug.Print AllText(Text1)
> > End Sub

> > Private Function AllText(TBArray As Object)
> >    Dim oTB As TextBox
> >    For Each oTB In TBArray
> >       AllText = AllText & oTB.Text & vbCrLf
> >    Next
> > End Function
> > '==========

> > --
> > Ken Halter - MS-MVP-VB - Please keep it in the groups..
> > http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


> > > I have the following code:

> > > private sub form_load()
> > >     call somefunction(check1)
> > > end sub

> > > private sub somefunction(SomeControl as Control)
> > >     code.....
> > > end sub

> > > If I use a standard control it passes if fine however if I use a
> > > control array I keep getting the type mismatch error.  How can I do
> > > this?



Thu, 30 Dec 2004 11:00:35 GMT  
 can a control array be passed to a function
Them darn whipper-snappers!... let 'um go play Nintendo ;-)

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm

Quote:

> Wow, my simple little comment invoked a lot of reminiscing.  I was
> also shocked to learn that both of you (Ken Halter & Unicorn) have a
> little bit of age on me or so it seems.  I am coming up on the big
> three-zero and even though that's relatively young while trolling
> these newsgroups you start to get the feeling that the big three-zero
> seem so ancient.  Lot of young kids in here now a days.



>> Thank you very much that worked like a charm.

>> It's amazing how much attention to detail you have to put into
>> writing a computer program.  You'd think with all the things
>> computers can do they would be a little more tuned to common sense.



>>> Sure.. if you drop an array of textboxes and a command button on a
>>> form, you'll see one way of doing it.. The code below just returns
>>> a string
> that
>>> contains all of the text from the textbox array that you pass to it.
>>> '==========
>>> Option Explicit

>>> Private Sub Command1_Click()
>>>    Debug.Print AllText(Text1)
>>> End Sub

>>> Private Function AllText(TBArray As Object)
>>>    Dim oTB As TextBox
>>>    For Each oTB In TBArray
>>>       AllText = AllText & oTB.Text & vbCrLf
>>>    Next
>>> End Function
>>> '==========

>>> --
>>> Ken Halter - MS-MVP-VB - Please keep it in the groups..
>>> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


>>>> I have the following code:

>>>> private sub form_load()
>>>>     call somefunction(check1)
>>>> end sub

>>>> private sub somefunction(SomeControl as Control)
>>>>     code.....
>>>> end sub

>>>> If I use a standard control it passes if fine however if I use a
>>>> control array I keep getting the type mismatch error.  How can I do
>>>> this?



Thu, 30 Dec 2004 12:26:29 GMT  
 can a control array be passed to a function
Hell, I'm 3 zero now, and I have a TRS80, a Colecovision ADAM, a Timex/Sinclar 1000, an Apple IIGs, and even a PET computer in
storage... LOL.  The one I always wanted, but never managed to get, the Amiga 500.  What a sweet piece of ass that was... hehe...

    WTH:)

Quote:

> Them darn whipper-snappers!... let 'um go play Nintendo ;-)

> --
> Ken Halter - MS-MVP-VB - Please keep it in the groups..
> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


> > Wow, my simple little comment invoked a lot of reminiscing.  I was
> > also shocked to learn that both of you (Ken Halter & Unicorn) have a
> > little bit of age on me or so it seems.  I am coming up on the big
> > three-zero and even though that's relatively young while trolling
> > these newsgroups you start to get the feeling that the big three-zero
> > seem so ancient.  Lot of young kids in here now a days.



> >> Thank you very much that worked like a charm.

> >> It's amazing how much attention to detail you have to put into
> >> writing a computer program.  You'd think with all the things
> >> computers can do they would be a little more tuned to common sense.



> >>> Sure.. if you drop an array of textboxes and a command button on a
> >>> form, you'll see one way of doing it.. The code below just returns
> >>> a string
> > that
> >>> contains all of the text from the textbox array that you pass to it.
> >>> '==========
> >>> Option Explicit

> >>> Private Sub Command1_Click()
> >>>    Debug.Print AllText(Text1)
> >>> End Sub

> >>> Private Function AllText(TBArray As Object)
> >>>    Dim oTB As TextBox
> >>>    For Each oTB In TBArray
> >>>       AllText = AllText & oTB.Text & vbCrLf
> >>>    Next
> >>> End Function
> >>> '==========

> >>> --
> >>> Ken Halter - MS-MVP-VB - Please keep it in the groups..
> >>> http://www.vbsight.com/ - http://www.vbsight.com/MultiColumn.htm


> >>>> I have the following code:

> >>>> private sub form_load()
> >>>>     call somefunction(check1)
> >>>> end sub

> >>>> private sub somefunction(SomeControl as Control)
> >>>>     code.....
> >>>> end sub

> >>>> If I use a standard control it passes if fine however if I use a
> >>>> control array I keep getting the type mismatch error.  How can I do
> >>>> this?



Thu, 30 Dec 2004 13:19:33 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. passing a control array to a function...

2. Passing control array into global function - problem

3. Passing control arrays into functions - how?

4. how do i pass control array to a function

5. Pass a control array to a function?

6. pass control array to function

7. How to pass a control array to a procedure or function

8. Passing in a control array to a Function??

9. Pass a control array to a function?

10. Passing Control Arrays to a function???

11. Passing a Control Array to a Function

12. Pass control array to sub/function ?

 

 
Powered by phpBB® Forum Software