473,480 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Strange combo box behavior

J L
I am trying to use the following code to auto fill a combo box
(credit and thanks to Code Project and Daryl)
Public Sub AutoFillCombo(ByVal theCombo As ComboBox, ByVal theKey As
Keys)
Dim sTypedText As String
Dim iFoundIndex As Integer
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String

Select Case theKey
Case Keys.Back, Keys.Left, Keys.Right, Keys.Delete, Keys.Down
Return
End Select

With theCombo
sTypedText = .Text
iFoundIndex = .FindString(sTypedText)
If iFoundIndex >= 0 Then
oFoundItem = .Items(iFoundIndex)
sFoundText = .GetItemText(oFoundItem)
sAppendText = sFoundText.Substring(sTypedText.Length)
.Text = sTypedText & sAppendText
.SelectionStart = sTypedText.Length
.SelectionLength = sAppendText.Length
End If
End With
End Sub

The problem is this: If I have the name John in my combo box and type
in john (that is, using a small letter j not J), it automatically
fills the box with the John not john. I checked sTypedText just before
the .Text assignment and it is small letter j. So when .Text is set,
it seems to find the John entry and uses it..or something...what am I
missing here?

TIA,
John

Nov 21 '05 #1
4 1188
J L
Opps, Just read further and see that the FindString search is not case
sensitive!

John

n Sun, 08 May 2005 07:45:57 -0700, J L <jo**@marymonte.com> wrote:
I am trying to use the following code to auto fill a combo box
(credit and thanks to Code Project and Daryl)
Public Sub AutoFillCombo(ByVal theCombo As ComboBox, ByVal theKey As
Keys)
Dim sTypedText As String
Dim iFoundIndex As Integer
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String

Select Case theKey
Case Keys.Back, Keys.Left, Keys.Right, Keys.Delete, Keys.Down
Return
End Select

With theCombo
sTypedText = .Text
iFoundIndex = .FindString(sTypedText)
If iFoundIndex >= 0 Then
oFoundItem = .Items(iFoundIndex)
sFoundText = .GetItemText(oFoundItem)
sAppendText = sFoundText.Substring(sTypedText.Length)
.Text = sTypedText & sAppendText
.SelectionStart = sTypedText.Length
.SelectionLength = sAppendText.Length
End If
End With
End Sub

The problem is this: If I have the name John in my combo box and type
in john (that is, using a small letter j not J), it automatically
fills the box with the John not john. I checked sTypedText just before
the .Text assignment and it is small letter j. So when .Text is set,
it seems to find the John entry and uses it..or something...what am I
missing here?

TIA,
John


Nov 21 '05 #2
J L
Double opps...the case sensitive search still does not explain why the
..Text seems to convert the sTypedText to upper case...so mystery
continues...

John

On Sun, 08 May 2005 07:45:57 -0700, J L <jo**@marymonte.com> wrote:
I am trying to use the following code to auto fill a combo box
(credit and thanks to Code Project and Daryl)
Public Sub AutoFillCombo(ByVal theCombo As ComboBox, ByVal theKey As
Keys)
Dim sTypedText As String
Dim iFoundIndex As Integer
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String

Select Case theKey
Case Keys.Back, Keys.Left, Keys.Right, Keys.Delete, Keys.Down
Return
End Select

With theCombo
sTypedText = .Text
iFoundIndex = .FindString(sTypedText)
If iFoundIndex >= 0 Then
oFoundItem = .Items(iFoundIndex)
sFoundText = .GetItemText(oFoundItem)
sAppendText = sFoundText.Substring(sTypedText.Length)
.Text = sTypedText & sAppendText
.SelectionStart = sTypedText.Length
.SelectionLength = sAppendText.Length
End If
End With
End Sub

The problem is this: If I have the name John in my combo box and type
in john (that is, using a small letter j not J), it automatically
fills the box with the John not john. I checked sTypedText just before
the .Text assignment and it is small letter j. So when .Text is set,
it seems to find the John entry and uses it..or something...what am I
missing here?

TIA,
John


Nov 21 '05 #3
Hi,

Here is a sample that works really well.
http://www.gotdotnet.com/Community/U...a-09bc8fd2860b

Ken
-------------------
"J L" <jo**@marymonte.com> wrote in message
news:t2********************************@4ax.com...
I am trying to use the following code to auto fill a combo box
(credit and thanks to Code Project and Daryl)
Public Sub AutoFillCombo(ByVal theCombo As ComboBox, ByVal theKey As
Keys)
Dim sTypedText As String
Dim iFoundIndex As Integer
Dim oFoundItem As Object
Dim sFoundText As String
Dim sAppendText As String

Select Case theKey
Case Keys.Back, Keys.Left, Keys.Right, Keys.Delete, Keys.Down
Return
End Select

With theCombo
sTypedText = .Text
iFoundIndex = .FindString(sTypedText)
If iFoundIndex >= 0 Then
oFoundItem = .Items(iFoundIndex)
sFoundText = .GetItemText(oFoundItem)
sAppendText = sFoundText.Substring(sTypedText.Length)
.Text = sTypedText & sAppendText
.SelectionStart = sTypedText.Length
.SelectionLength = sAppendText.Length
End If
End With
End Sub

The problem is this: If I have the name John in my combo box and type
in john (that is, using a small letter j not J), it automatically
fills the box with the John not john. I checked sTypedText just before
the .Text assignment and it is small letter j. So when .Text is set,
it seems to find the John entry and uses it..or something...what am I
missing here?

TIA,
John
Nov 21 '05 #4
JL,

I was making a new sample for you yesterday, the one you use now has in my
idea needles to much sentences, I did not succeed directly and had to go,
however I see now that Ken supplied one. Your problem is probably that Jonh
is found in the items, and replaces that in the textbox (what it should do).

Cor
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3292
by: will eichert | last post by:
Greetings. I have a problem with a combo box incorrectly displaying blank items when returning to a form from a modal form. It's fine when the main form first comes up, but gets messed up when the...
0
1197
by: Jonathan LaRosa | last post by:
This is wierd: A client of mine has a combo box on a form that has a list of school names. She has found a wierd error when she tries to search for a specific school. She is trying to type in...
3
1442
by: Karl Roes | last post by:
Hi All, I have a form with a standard combo box and 5 tabs in A2003. On Form Open, I set Me.Detail.Visible = False and in the after update event of the combo set Me.Detail.Visible = True,( to...
1
1412
by: Edward | last post by:
I have encountered a combo box acting with a mind of its own in a VB.NET Windows app. I have a wizard consisting of a tab control; depending on which page is being displayed the tabs are added...
1
2011
by: Peter Proost | last post by:
Hi group I've got a usercontrol containing a textbox and alongside the textbox there's a combobox. I draw this control on top of a grid. So when the user clicks certain columns in the grid the...
2
1497
by: sara | last post by:
I have a simple form with a combo box on top and then when a record is chosen the remaining 3 fields from the table on the form. My problem is that if I open the form on its own, all is fine. I...
8
2178
by: AA Arens | last post by:
Hi I do have a products table and products-parts table in my Access 2003 database and log all services into a form. I do have at least the following two combo boxes on my form: - Choose...
1
1613
by: John Kreps | last post by:
I've tried to get combo boxes to work with Access 2007 for days now without success. What I can't get to work is the autocomplete. I've got three simple tables and one form with two controls....
2
3726
by: scdowney | last post by:
First and foremost, thank you in advance for any attempts to help me out. I am working on a project with work, and it requires I use CSS selectors to locate elements within a webpage. For the...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7045
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7087
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6741
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.