|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Access collection using keyHi, I've set up a collection to keep track of forms. I've used the forms
caption as the key to each object in the collection to keep track of which forms are stored in it. My question is how can I now use the key to determine if that form has already been loaded? I can loop through the collection but I only seem to be able to reference the count which doesn't seem to help my problem. Any suggestions would be much appreciated Ant Set FormFormCol = colForms(strYourKey)
should do what you want. If this line of code fails the form is not included in the collection. By the way, there is no need to create such a collection by yourself. VB already offers the "Forms" collection which might be exactly what you need. Show quoteHide quote >Hi, I've set up a collection to keep track of forms. I've used the forms >caption as the key to each object in the collection to keep track of which >forms are stored in it. My question is how can I now use the key to determine >if that form has already been loaded? I can loop through the collection but I >only seem to be able to reference the count which doesn't seem to help my >problem. Any suggestions would be much appreciated > >Ant Hello Marcus,
Thanks very much; That did it. I also looked for the forms collection but I couldn't find such an object 'Forms'. I'm using VB6 (SP3). You might be referring to .NET (?) Doesn't really matter as this collection does fine. Thanks again. Show quoteHide quote "Markus Weber (Megalith GmbH)" wrote: > Set FormFormCol = colForms(strYourKey) > > should do what you want. If this line of code fails the form is not > included in the collection. > > By the way, there is no need to create such a collection by yourself. > VB already offers the "Forms" collection which might be exactly what > you need. > > >Hi, I've set up a collection to keep track of forms. I've used the forms > >caption as the key to each object in the collection to keep track of which > >forms are stored in it. My question is how can I now use the key to determine > >if that form has already been loaded? I can loop through the collection but I > >only seem to be able to reference the count which doesn't seem to help my > >problem. Any suggestions would be much appreciated > > > >Ant > > "Ant" <A**@discussions.microsoft.com> wrote in message news:B209CFFB- 7C3F-4C65-AB6F-8860F07AC***@microsoft.com> Hello Marcus, The Forms collection is a standard part of VB6.. add this to your code> Thanks very much; That did it. I also looked for the forms collection > but I couldn't find such an object 'Forms'. I'm using VB6 (SP3). somewhere: dim f as form for each f in Forms debug.print f.Name next -- Reply to the group so all can participate VB.Net: "Fool me once..." "Bob Butler" <tiredofit@nospam.com> wrote in message Does the Forms collection have a key or is it only accessible by index? I'm news:u01P9HTYFHA.3212@TK2MSFTNGP10.phx.gbl... >> Thanks very much; That did it. I also looked for the forms collection >> but I couldn't find such an object 'Forms'. I'm using VB6 (SP3). > > The Forms collection is a standard part of VB6.. add this to your code > somewhere: > > dim f as form > for each f in Forms > debug.print f.Name > next betting on the latter, so it won't solve the poster's original problem.
Show quote
Hide quote
"Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message It only works by index but it'd be easy enough to loop through thenews:u4J8DpTYFHA.1412@TK2MSFTNGP12.phx.gbl > "Bob Butler" <tiredofit@nospam.com> wrote in message > news:u01P9HTYFHA.3212@TK2MSFTNGP10.phx.gbl... > >>> Thanks very much; That did it. I also looked for the forms >>> collection but I couldn't find such an object 'Forms'. I'm using >>> VB6 (SP3). >> >> The Forms collection is a standard part of VB6.. add this to your >> code somewhere: >> >> dim f as form >> for each f in Forms >> debug.print f.Name >> next > > Does the Forms collection have a key or is it only accessible by > index? I'm betting on the latter, so it won't solve the poster's > original problem. collection looking for the desired form. Even with a lot of forms it would not take long. I was only responding to the part that said he "couldn't find such an object 'Forms'" though. Building his own collection should work just fine also. -- Reply to the group so all can participate VB.Net: "Fool me once..." VB 6 has a Forms collection. VB.Net uses native Windows API based forms and
as such, doesn't have a forms collection. This is probably the single biggest difference between VB 6 and VB.Net. Mike Ober. Show quoteHide quote "Ant" <A**@discussions.microsoft.com> wrote in message news:B209CFFB-7C3F-4C65-AB6F-8860F07AC8F7@microsoft.com... > Hello Marcus, > Thanks very much; That did it. I also looked for the forms collection but I > couldn't find such an object 'Forms'. I'm using VB6 (SP3). You might be > referring to .NET (?) > Doesn't really matter as this collection does fine. > Thanks again. > > > "Markus Weber (Megalith GmbH)" wrote: > > > Set FormFormCol = colForms(strYourKey) > > > > should do what you want. If this line of code fails the form is not > > included in the collection. > > > > By the way, there is no need to create such a collection by yourself. > > VB already offers the "Forms" collection which might be exactly what > > you need. > > > > >Hi, I've set up a collection to keep track of forms. I've used the forms > > >caption as the key to each object in the collection to keep track of which > > >forms are stored in it. My question is how can I now use the key to determine > > >if that form has already been loaded? I can loop through the collection but I > > >only seem to be able to reference the count which doesn't seem to help my > > >problem. Any suggestions would be much appreciated > > > > > >Ant > > > > > "Michael D. Ober" <ober***@.alum.mit.edu.nospam> wrote in message I think it'd be difficult to identify any *single biggest difference*!news:4Dale.643$MI4.401@newsread2.news.pas.earthlink.net > VB 6 has a Forms collection. VB.Net uses native Windows API based > forms and as such, doesn't have a forms collection. This is probably > the single biggest difference between VB 6 and VB.Net. -- Reply to the group so all can participate VB.Net: "Fool me once..." |
|||||||||||||||||||||||