?
Solved

VB 6 combo box problem

Posted on 2010-11-29
13
Medium Priority
?
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
13 Comments
 
LVL 14

Accepted Solution

by:
Brook Braswell earned 1000 total points
ID: 34232957
Make the Combo Box a style of 2 - DropDown List
0
 

Assisted Solution

by:Taki Elias
Taki Elias earned 500 total points
ID: 34233022
Check The Properties Of Combo box Style > Select ? Drop Down list
0
 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 500 total points
ID: 34233140
This is what you need to set in visual mode:
ScreenShot.png
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

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

Expert Comment

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

Author Comment

by:rfedorov
ID: 34241982
no, like something preventing the user type in, using let say If statements...
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 34241984
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
ID: 34242002
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
ID: 34242012
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
ID: 34242024
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
ID: 34242053
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
ID: 34242058
@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 1000 total points
ID: 34242085
not a key event but a click event
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

752 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