1 Replies - 2167 Views - Last Post: 19 March 2008 - 10:42 AM Rate Topic: -----

#1 v0id1987   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-March 08

Prevent Same Data from Entering in a ComboBox

Posted 17 March 2008 - 11:11 PM

Heres the two sets of code i work at, the first one doesn't work and the second one seems to work sometimes(Logic error involved i believe)

1st set
   Do Until cboCar.Text = cboCar.List(cboCar.ListIndex)
	
		If cboCar.Text <> cboCar.List(cboCar.ListIndex) Then
			cboCar.AddItem cboCar.Text
			
		Else
			MsgBox "Already There"
		 
		End If
	 Loop



2nd set
'	If cboCar.Text <> cboCar.List(cboCar.ListIndex) Then
		
'		Do
'			cboCar.AddItem cboCar.Text
'			''Add to combo box
			
'		Loop Until cboCar.Text <> cboCar.List(cboCar.ListIndex)
'
'	Else
'
 '		   MsgBox "Already There"
  '		  ''Display Textbox if it's in the combo box already
   ' End If




Basically, i want the program to give a pop up if the data is in the combobox already. if it's not enter, then i want to add it into the combobox. Tell me what i am doing wrong.

Is This A Good Question/Topic? 0
  • +

Replies To: Prevent Same Data from Entering in a ComboBox

#2 LookNAO   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 66
  • Joined: 28-December 07

Re: Prevent Same Data from Entering in a ComboBox

Posted 19 March 2008 - 10:42 AM

View Postv0id1987, on 17 Mar, 2008 - 11:11 PM, said:

Heres the two sets of code i work at, the first one doesn't work and the second one seems to work sometimes(Logic error involved i believe)

1st set
   Do Until cboCar.Text = cboCar.List(cboCar.ListIndex)
	
		If cboCar.Text <> cboCar.List(cboCar.ListIndex) Then
			cboCar.AddItem cboCar.Text
			
		Else
			MsgBox "Already There"
		 
		End If
	 Loop



2nd set
'	If cboCar.Text <> cboCar.List(cboCar.ListIndex) Then
		
'		Do
'			cboCar.AddItem cboCar.Text
'			''Add to combo box
			
'		Loop Until cboCar.Text <> cboCar.List(cboCar.ListIndex)
'
'	Else
'
 '		   MsgBox "Already There"
  '		  ''Display Textbox if it's in the combo box already
   ' End If




Basically, i want the program to give a pop up if the data is in the combobox already. if it's not enter, then i want to add it into the combobox. Tell me what i am doing wrong.



In both code examples you have here you are trying to populate a combobox with what ever the combobox.text has in it...

The first one is looking for something in the (cbocar.listindex) which is going to equal 0.

The second is going to go into a constant Do...Loop until it errors out, running out of memory probably...


My question; What are you trying to do??? The code you have is trying to just fill the combobox .list with what's in the .text. Are you trying to fill the combobox maybe from anoter list???

LookNaO
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1