PC Review


Reply
Thread Tools Rate Thread

Combobox.FindStringExact--doesn't find text that I KNOW is there.

 
 
rdi
Guest
Posts: n/a
 
      2nd Apr 2004
I've got a combo-box of the drop-down style (not drop-down-list). The first item is "NHPI-Forms". If I type "NHPI-Forms" into the combo-box that string is supposedly not listed in the combo-box. While if I type "Personal" (which is the THIRD item in the list, it IS found. I'm using "FindStringExact" from the combo-box. WHat could be going on?


TIA

--

RDI

(remove the exclamation from the email address)


'This is performed as part of the initialization of the form
cbxAcctAcctList.Items.Add("NHPI-Forms")
cbxAcctAcctList.Items.Add("NHPI-AutoResponder")
cbxAcctAcctList.Items.Add("Personal")

'This is what happens if I type something into the combobox.
'If I type "NHPI-Forms", the FIRST portion of the IF statement occurs
'if I type "Personal", the SECOND portion of the IF statement occurs
Private Sub cbxAcctAcctList_NewText(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxAcctAcctList.TextChanged
If cbxAcctAcctList.FindStringExact(cbxAcctAcctList.Text) Then
BtnAcctRmv.Enabled = True
btnAcctMod.Enabled = True
btnAcctAdd.Enabled = False
Else
BtnAcctRmv.Enabled = False
btnAcctMod.Enabled = False
btnAcctAdd.Enabled = True
End If
End Sub

 
Reply With Quote
 
 
 
 
rdi
Guest
Posts: n/a
 
      2nd Apr 2004
Never mind. Shortly after hitting send, the answer hit me. Find string returns an integer. If the string is NOT found, it returns -1. If it IS found, it returns the index to it.

The following worked fine.

Private Sub cbxAcctAcctList_NewText(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxAcctAcctList.TextChanged
If cbxAcctAcctList.FindStringExact(cbxAcctAcctList.Text) >= 0 Then
BtnAcctRmv.Enabled = True
btnAcctMod.Enabled = True
btnAcctAdd.Enabled = False
Else
BtnAcctRmv.Enabled = False
btnAcctMod.Enabled = False
btnAcctAdd.Enabled = True
End If
End Sub

--

RDI

(remove the exclamation from the email address)

"rdi" <rdi!@writeme.com> wrote in message news:%(E-Mail Removed)...
I've got a combo-box of the drop-down style (not drop-down-list). The first item is "NHPI-Forms". If I type "NHPI-Forms" into the combo-box that string is supposedly not listed in the combo-box. While if I type "Personal" (which is the THIRD item in the list, it IS found. I'm using "FindStringExact" from the combo-box. WHat could be going on?


TIA

--

RDI

(remove the exclamation from the email address)


'This is performed as part of the initialization of the form
cbxAcctAcctList.Items.Add("NHPI-Forms")
cbxAcctAcctList.Items.Add("NHPI-AutoResponder")
cbxAcctAcctList.Items.Add("Personal")

'This is what happens if I type something into the combobox.
'If I type "NHPI-Forms", the FIRST portion of the IF statement occurs
'if I type "Personal", the SECOND portion of the IF statement occurs
Private Sub cbxAcctAcctList_NewText(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxAcctAcctList.TextChanged
If cbxAcctAcctList.FindStringExact(cbxAcctAcctList.Text) Then
BtnAcctRmv.Enabled = True
btnAcctMod.Enabled = True
btnAcctAdd.Enabled = False
Else
BtnAcctRmv.Enabled = False
btnAcctMod.Enabled = False
btnAcctAdd.Enabled = True
End If
End Sub

 
Reply With Quote
 
yEah rIgHt
Guest
Posts: n/a
 
      2nd Apr 2004
I tried it and it returned 0, which is correct. So your if statement
will return False because 0 is considered False.

'-- Will be false if number is zero
If cbxAcctAcctList.FindStringExact(cbxAcctAcctList.Text) Then

'-- You should change it to this:
If cbxAcctAcctList.FindStringExact(cbxAcctAcctList.Text) > -1 Then


> I've got a combo-box of the drop-down style (not drop-down-list). The
> first item is "NHPI-Forms". If I type "NHPI-Forms" into the combo-box
> that string is supposedly not listed in the combo-box. While if I type
> "Personal" (which is the THIRD item in the list, it IS found. I'm using
> "FindStringExact" from the combo-box. WHat could be going on?
>
> TIA
>
> --
>
> RDI
>
> (remove the exclamation from the email address)
>
> 'This is performed as part of the initialization of the form
> cbxAcctAcctList.Items.Add("NHPI-Forms")
> cbxAcctAcctList.Items.Add("NHPI-AutoResponder")
> cbxAcctAcctList.Items.Add("Personal")
>
> 'This is what happens if I type something into the combobox.
> 'If I type "NHPI-Forms", the FIRST portion of the IF statement occurs
> 'if I type "Personal", the SECOND portion of the IF statement occurs
> Private Sub cbxAcctAcctList_NewText(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles cbxAcctAcctList.TextChanged
> If cbxAcctAcctList.FindStringExact(cbxAcctAcctList.Text) Then
> BtnAcctRmv.Enabled = True
> btnAcctMod.Enabled = True
> btnAcctAdd.Enabled = False
> Else
> BtnAcctRmv.Enabled = False
> btnAcctMod.Enabled = False
> btnAcctAdd.Enabled = True
> End If
> End Sub
>

 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      2nd Apr 2004
"rdi" <rdi!@writeme.com> schrieb
> Never mind. Shortly after hitting send, the answer hit me. Find
> string returns an integer. If the string is NOT found, it returns -1.
> If it IS found, it returns the index to it.


Option Strict On helps.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search doesn't find text that is present Paul Microsoft Word Document Management 3 27th Jul 2009 06:59 PM
OL2000/W2K - Find box doesn't allow text input Microsoft Outlook Installation 1 15th Jun 2007 12:51 AM
OL2000/W2K - Find box doesn't allow text input Microsoft Outlook Interoperability 1 15th Jun 2007 12:51 AM
Find text doesn't work in Word in text copied from other document =?Utf-8?B?SGFpbQ==?= Microsoft Word Document Management 4 3rd Oct 2006 06:24 PM
PLS HELP: How to find ot if text fits a texbox/combobox MuZZy Microsoft C# .NET 1 10th May 2005 07:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 AM.