I have a combobox where a user can select a zoom factor or enter a
zoom factor.
I tried to limit entry into the combobox to numbers only by catching
the keydown event and setting e.handled = true if any non number
characters are entered.
But those characters still appear in the combobox. Is this a combobox
bug?
If yes any workarounds?
Tosch 10 9075
Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a':
If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message
news:18********************************@4ax.com... I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch
Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a':
If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message
news:18********************************@4ax.com... I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch
This is my code and it's not working. I want only numbers 0-9
accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
Select Case e.KeyChar
Case "0" To "9"
Case Else
e.Handled = True
End Select
End Sub
BTW: I'm using VS2002.
Tosch
On Thu, 11 Nov 2004 09:58:23 -0500, "Bernie Yaeger"
<be*****@cherwellinc.com> wrote: Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a': If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message news:18********************************@4ax.com.. .I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch
This is my code and it's not working. I want only numbers 0-9
accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
Select Case e.KeyChar
Case "0" To "9"
Case Else
e.Handled = True
End Select
End Sub
BTW: I'm using VS2002.
Tosch
On Thu, 11 Nov 2004 09:58:23 -0500, "Bernie Yaeger"
<be*****@cherwellinc.com> wrote: Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a': If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message news:18********************************@4ax.com.. .I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch
Tosch,
Tosch,
Some hours ago I showed this sample too EDB he told me that it was what he
wanted, however, that it can be optimized, and he is right, it where first
two samples. http://groups.google.com/groups?selm...TNGP12.phx.gbl
I did not change them yet.
I hope however that it helps you as well.
Cor
"Tosch" <to**********@swissonline.ch> This is my code and it's not working. I want only numbers 0-9 accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress Select Case e.KeyChar Case "0" To "9" Case Else e.Handled = True End Select End Sub
BTW: I'm using VS2002.
Tosch
On Thu, 11 Nov 2004 09:58:23 -0500, "Bernie Yaeger" <be*****@cherwellinc.com> wrote:
Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a': If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message news:18********************************@4ax.com. ..I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch
Tosch,
Tosch,
Some hours ago I showed this sample too EDB he told me that it was what he
wanted, however, that it can be optimized, and he is right, it where first
two samples. http://groups.google.com/groups?selm...TNGP12.phx.gbl
I did not change them yet.
I hope however that it helps you as well.
Cor
"Tosch" <to**********@swissonline.ch> This is my code and it's not working. I want only numbers 0-9 accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress Select Case e.KeyChar Case "0" To "9" Case Else e.Handled = True End Select End Sub
BTW: I'm using VS2002.
Tosch
On Thu, 11 Nov 2004 09:58:23 -0500, "Bernie Yaeger" <be*****@cherwellinc.com> wrote:
Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a': If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message news:18********************************@4ax.com. ..I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch
"Tosch" <to**********@swissonline.ch> schrieb: This is my code and it's not working. I want only numbers 0-9 accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress Select Case e.KeyChar Case "0" To "9" Case Else e.Handled = True End Select End Sub
BTW: I'm using VS2002.
IIRC that's caused by the buggy implementation of the combobox.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
"Tosch" <to**********@swissonline.ch> schrieb: This is my code and it's not working. I want only numbers 0-9 accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress Select Case e.KeyChar Case "0" To "9" Case Else e.Handled = True End Select End Sub
BTW: I'm using VS2002.
IIRC that's caused by the buggy implementation of the combobox.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Hi Tosch,
I tried your code inside vs 2003, which is all that I work with, and it
worked fine. So the answer has to be that there's a bug in 2002. Also, you
have to add a few characters - backspace, delete, arrow keys, etc. So you
may want to modify your code, into something like this:
Dim KeyAscii As Integer = Asc(e.KeyChar)
Select Case KeyAscii
Case 8, 27, 48 To 57, 9
Case Else
KeyAscii = 0
End Select
If KeyAscii = 0 Then
e.Handled = True
Else
e.Handled = False
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message
news:8r********************************@4ax.com... This is my code and it's not working. I want only numbers 0-9 accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress Select Case e.KeyChar Case "0" To "9" Case Else e.Handled = True End Select End Sub
BTW: I'm using VS2002.
Tosch
On Thu, 11 Nov 2004 09:58:23 -0500, "Bernie Yaeger" <be*****@cherwellinc.com> wrote:
Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a': If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message news:18********************************@4ax.com. ..I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch
Hi Tosch,
I tried your code inside vs 2003, which is all that I work with, and it
worked fine. So the answer has to be that there's a bug in 2002. Also, you
have to add a few characters - backspace, delete, arrow keys, etc. So you
may want to modify your code, into something like this:
Dim KeyAscii As Integer = Asc(e.KeyChar)
Select Case KeyAscii
Case 8, 27, 48 To 57, 9
Case Else
KeyAscii = 0
End Select
If KeyAscii = 0 Then
e.Handled = True
Else
e.Handled = False
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message
news:8r********************************@4ax.com... This is my code and it's not working. I want only numbers 0-9 accepted:
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress Select Case e.KeyChar Case "0" To "9" Case Else e.Handled = True End Select End Sub
BTW: I'm using VS2002.
Tosch
On Thu, 11 Nov 2004 09:58:23 -0500, "Bernie Yaeger" <be*****@cherwellinc.com> wrote:
Hi Tosch,
Use the keypress event. The following worked fine for me, disallowing 'a': If e.KeyChar = "a" Then
e.Handled = True
End If
HTH,
Bernie Yaeger
"Tosch" <to**********@swissonline.ch> wrote in message news:18********************************@4ax.com. ..I have a combobox where a user can select a zoom factor or enter a zoom factor. I tried to limit entry into the combobox to numbers only by catching the keydown event and setting e.handled = true if any non number characters are entered. But those characters still appear in the combobox. Is this a combobox bug? If yes any workarounds?
Tosch This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Iain Miller |
last post by:
Struggling a bit here & would be grateful for any help.
I have a table which has a list of people in it. Each person has a unique ID
automatically allocated by Access but also belongs to one of 5...
|
by: Nancy |
last post by:
I have two tables:
TblCourse
CourseID
CourseName
TblClass
ClassID
CourseID
ClassDate
|
by: Trent |
last post by:
I am in the design phase of a new database and am having a devil of a
time with a subform.
I have three tables that relate to problem - Suppliers tbl, Customers
tbl and a SuppliersCustomers tbl....
|
by: Tosch |
last post by:
I have a combobox where a user can select a zoom factor or enter a
zoom factor.
I tried to limit entry into the combobox to numbers only by catching
the keydown event and setting e.handled = true...
|
by: Melson |
last post by:
Hi
I've a problem. Can anyone help. I would like to use datagrid for data
entry. How can I set the number of rows in the datagrid. And use the
datagrid to update the ms sql table.
regards...
|
by: Caro |
last post by:
Hello,
Is it possible to create a sort of validation rule that will limit the
data entry in a field to even numbers only ?
thaks,
Caro
|
by: tizmagik |
last post by:
I have a combobox on a continuous form that has a recordsource that is
set upon Form_Load event via VBA (based on initial form data and
external form data entered). For data entry purposes the...
|
by: nt8jbwu02 |
last post by:
I would like to allow a user to enter an ip address (quad octet format:
www.xxx.yyy.zzz) in a combo box and then add it to the list when they
have completed the entry.
How can I do this?
The...
|
by: injanib via AccessMonster.com |
last post by:
is it possible that if the limit to list property of a combobox is set to
true the focus is passed onto another field? What I mean is that I have a
combo box with the limit to list property set to...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
| |