From: Ed from AZ on
While searching for information on search-list-as-you-type feasability
and code, I came across a 2002 newsgroup thread that included a post
from Stefan Berglund:

http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_thread/thread/4288b9419c107a19?hl=en

In his post, Stefan gave code for a class module that would allow the
search as you type or type ahead functionality in a combo box. It
works great!!

I would like to see about modifying it a bit. What I would like to do
is to have four combo boxes, each populated with a different list, and
what I type affecting the list in each of the four combo boxes. I
would then click a button to indicate which of the four selections I
wanted.

I'm very unfamiliar with a lot of what's happening in Stefan's code
(that's why I used his rather than writing my own!!). It would seem
that all I would need to do is in the Form_Load code iterate through
each combobox and set class objects to each of the combos:

Private Sub Form_Load()

Set m_clsCombo1 = New clsControlCombo
Set m_clsCombo1.Control = Combo1

Set m_clsCombo2 = New clsControlCombo
Set m_clsCombo2.Control = Combo12

etc.

End Sub

But then I am not sure about
-- how do I get what I type into each combobox simultaneously?
-- and will Stefan's code run in each combobox simultaneously without
causing a conflict that I wouldn't be able to decipher or resolve?

Any input is greatly appreciated.

Ed
Using VB6SP2 Learning Edition in WinXPSP2.
Note: this is only for personal use, and not for distrubution to
anyone else.
From: MikeD on

"Ed from AZ" <prof_ofwhat(a)yahoo.com> wrote in message news:83a80c6a-6651-4323-83b6-0742f96d24ee(a)25g2000hsx.googlegroups.com...
> While searching for information on search-list-as-you-type feasability
> and code, I came across a 2002 newsgroup thread that included a post
> from Stefan Berglund:
>
> http://groups.google.com/group/microsoft.public.vb.general.discussion/browse_thread/thread/4288b9419c107a19?hl=en
>
> In his post, Stefan gave code for a class module that would allow the
> search as you type or type ahead functionality in a combo box. It
> works great!!
>
> I would like to see about modifying it a bit. What I would like to do
> is to have four combo boxes, each populated with a different list, and
> what I type affecting the list in each of the four combo boxes. I
> would then click a button to indicate which of the four selections I
> wanted.
>
> I'm very unfamiliar with a lot of what's happening in Stefan's code
> (that's why I used his rather than writing my own!!). It would seem
> that all I would need to do is in the Form_Load code iterate through
> each combobox and set class objects to each of the combos:
>
> Private Sub Form_Load()
>
> Set m_clsCombo1 = New clsControlCombo
> Set m_clsCombo1.Control = Combo1
>
> Set m_clsCombo2 = New clsControlCombo
> Set m_clsCombo2.Control = Combo12
>
> etc.
>
> End Sub
>
> But then I am not sure about
> -- how do I get what I type into each combobox simultaneously?
> -- and will Stefan's code run in each combobox simultaneously without
> causing a conflict that I wouldn't be able to decipher or resolve?
>
> Any input is greatly appreciated.
>


I'm not really sure what you're asking. A class module is basically a template for creating an object. That's it. In the above
code, you're creating a new object from this class for each of the 2 comboboxes. So, each object (referenced by the variables
m_clsCombo1 and m_clsCombo2, respectively) is distinct from one another.

--
Mike
Microsoft Visual Basic MVP



From: Steve Gerrard on
Ed from AZ wrote:

> But then I am not sure about
> -- how do I get what I type into each combobox simultaneously?

If you are typing in Combo1, use the Combo1_Change event to assign the text of
Combo1 to the other three combos.

Don't do the same thing in the other three, though. That would get you into an
event loop. If you need that, you can use a flag to block it from looping.

> -- and will Stefan's code run in each combobox simultaneously without
> causing a conflict that I wouldn't be able to decipher or resolve?

Yes, although simulataneous is in the eye of the beholder.



From: Ed from AZ on
Mike:
>> So, each object (referenced by the variables
>> m_clsCombo1 and m_clsCombo2, respectively)
>> is distinct from one another.

Thank you for the explanation. As I said, there's a lot in this that
goes way over my head. I always apreciate the help I receive to
understand things.


Steve:
>> If you are typing in Combo1, use the
>> Combo1_Change event to assign the text of
>> Combo1 to the other three combos.

In Stefan's class module is a Control_Change sub:
Private Sub Control_Change()
With Control
If (Len(.Tag) = 0 And Not mbCancel) Then
Dim strText As String
strText = .Text
Dim lngID As Long
lngID = FindComboMatch(Control, strText)
If (lngID >= 0) Then
.Tag = "x"
.Text = .List(lngID)
.SelStart = Len(strText)
.SelLength = Len(.Text)
.Tag = ""
End If
End If
End With
End Sub

I'm assuming this _Change event would be separate from the
Combo1_Change or Combo2_Change events? And there's no conflicts
caused by running the class module Combo_Change and the Combo1_Change
at the same time?

> Don't do the same thing in the other three, though.
> That would get you into an event loop. If you need
>> that, you can use a flag to block it from looping.

Would it be better to have a fifth control, like a textbox, and use
that _Change event to populate all four combos?

Also, in Stefan's class there is a Control_KeyDown sub. If I am
populating the combos by pulling the text from another control, the
second combo will never see the _KeyDown event, will it? Can I /
should I assign these events to other subs and call them for each
combo as I populate it?

Ed


From: Larry Serflaten on

"Ed from AZ" <prof_ofwhat(a)yahoo.com> wrote

> Would it be better to have a fifth control, like a textbox, and use
> that _Change event to populate all four combos?
>
> Also, in Stefan's class there is a Control_KeyDown sub. If I am
> populating the combos by pulling the text from another control, the
> second combo will never see the _KeyDown event, will it? Can I /
> should I assign these events to other subs and call them for each
> combo as I populate it?


It would probably be better to decide how you want it to respond,
and then add the code necessary to do that. From what you said
earlier:

"I would like to see about modifying it a bit. What I would like to do
is to have four combo boxes, each populated with a different list, and
what I type affecting the list in each of the four combo boxes. I
would then click a button to indicate which of the four selections I
wanted."

I have to wonder why you are using 4 combo boxes. It would seem
one larger list might suffice, or four separate listsboxes with a textbox
as that fifth input control.

Another (wierd) approach would have all the text portions of the 4
combo boxes respond identically. No matter which you type in,
they all react as if someone was typing in them.

But, at this point, I would suggest a better description of the entire
task would be benificial. There may be 'more user friendly' ways
to do what you want. As it is, it is hard to imagine why you would
want entry from one control to affect 3 others....

LFS