Solved

VB 6 combo box problem

Posted on 2010-11-29
13
397 Views
Last Modified: 2012-05-10
I have a combo box, let called it ZipCode
So, you have to select the appropriate zip code selecting from the combo box
Right now you can just type in the field   instead of selecting.
How to prevent the user from typing anything in the combo box and make sure that the only way to select the value is to select from the combo box
0
Comment
Question by:rfedorov
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 14

Accepted Solution

by:
Brook Braswell earned 250 total points
Comment Utility
Make the Combo Box a style of 2 - DropDown List
0
 

Assisted Solution

by:Taki Elias
Taki Elias earned 125 total points
Comment Utility
Check The Properties Of Combo box Style > Select ? Drop Down list
0
 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 125 total points
Comment Utility
This is what you need to set in visual mode:
ScreenShot.png
0
 

Author Comment

by:rfedorov
Comment Utility
Thank you, but anybody knows how to validate through the code?
I need my style=0
0
 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
What do you mean by "validate through the code"?
Combo1.Style = 0
0
 

Author Comment

by:rfedorov
Comment Utility
no, like something preventing the user type in, using let say If statements...
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
You said: >How to prevent the user from typing anything in the combo box and make sure that the only way to select the value is to select from the combo box<

But to set the style to 0, you allow user to type into the combo box. Is this what you want?
0
 

Author Comment

by:rfedorov
Comment Utility
I know that...
but for what ever reason i am getting the error, when i am changing the style =2...
0
 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
Try this:
Private Sub Combo1_KeyPress(KeyAscii As Integer)

    KeyAscii = 0

End Sub

Open in new window

0
 
LVL 14

Expert Comment

by:Brook Braswell
Comment Utility
If your style is 2 then when they user types 3 it would find the first zip code beginning with 3
what are you trying to allow the user to have with style 0 that they would loose with style 2?
0
 
LVL 14

Expert Comment

by:Brook Braswell
Comment Utility
What error are you getting?

The most common is that you are attempting to set the combo box equal to a value that is NOT in the list of items
Example...

box populated with
30012
30014
30016

your recordset has a value of 30015
and you set datasource to recordset

In order to overcome this you must make sure the data matches the available list.
0
 
LVL 17

Expert Comment

by:Zhaolai
Comment Utility
@Brook1966, by setting the style to 2, the control does not respond to any key event.
0
 
LVL 14

Assisted Solution

by:Brook Braswell
Brook Braswell earned 250 total points
Comment Utility
not a key event but a click event
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now