By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

Replace a character in combo box

P: n/a
Kay
Hi All,

I'm trying to write a small sub/function to replace some (invalid) character
in a combo box, or may be even text box. For example, I have several combo
boxes that allows user to select a time value, i.e. 21:30, however I also
want to allow them to enter a time, as a result I want to replace comma,
fullstop etc with a colon ":". I've done this in VB6 keypress event,
however with the "sender", "e" in .net I'm a bit lost... I don't have much
experience in .net could you guys give me some help?

Thanks!

Kay

Aug 22 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Kay,

Here is an autocomplete sample for a combobox, in my idea are all the
ingredients in that to make what you want. (It begins with building a
sample).

http://www.vb-tips.com/dbPages.aspx?...f-c22411591992

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:%2******************@TK2MSFTNGP05.phx.gbl...
Hi All,

I'm trying to write a small sub/function to replace some (invalid)
character
in a combo box, or may be even text box. For example, I have several
combo
boxes that allows user to select a time value, i.e. 21:30, however I also
want to allow them to enter a time, as a result I want to replace comma,
fullstop etc with a colon ":". I've done this in VB6 keypress event,
however with the "sender", "e" in .net I'm a bit lost... I don't have much
experience in .net could you guys give me some help?

Thanks!

Kay

Aug 22 '06 #2

P: n/a
Kay
Hi Cor & all,

Core thanks for your response, I have a look on your web site, but I think
it may be a bit difficult if I want to use it for a text box - after I think
again what I really want - if it's possible I want to create a function,
with a papramater, then check whether it's a valid character, i.e. in this
case ":" & number are valid, if not cancel the character entered, or replace
with other character....um... that sounds good to me but if you guys have a
better advice please tell me!! So now the problem I have is how to capture
the character just entered....

Kay

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
Kay,

Here is an autocomplete sample for a combobox, in my idea are all the
ingredients in that to make what you want. (It begins with building a
sample).

http://www.vb-tips.com/dbPages.aspx?...f-c22411591992

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:%2******************@TK2MSFTNGP05.phx.gbl...
>Hi All,

I'm trying to write a small sub/function to replace some (invalid)
character
in a combo box, or may be even text box. For example, I have several
combo
boxes that allows user to select a time value, i.e. 21:30, however I also
want to allow them to enter a time, as a result I want to replace comma,
fullstop etc with a colon ":". I've done this in VB6 keypress event,
however with the "sender", "e" in .net I'm a bit lost... I don't have
much
experience in .net could you guys give me some help?

Thanks!

Kay


Aug 22 '06 #3

P: n/a
Kay,

Have a look at the thenthousand samples about a numeric textbox on Internet
by using Google.

I have not set this one on our site, because there is nothing in it for
pushing the del key etc.
Especially for your question, use the keyup event most people want to use
the key down, which gives less information in the KeyEventArgs.

\\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.MaxLength = 10
End Sub
Private Sub textbox1_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles textbox1.KeyUp
If e.KeyValue <8 Then
If Not IsNumeric(TextBox1.Text) Then
If TextBox1.Text.Length 0 Then
MessageBox.Show("Only numeric is allowed")

TextBox1.SelectionStart = TextBox1.Text.Length - 1
TextBox1.SelectionLength = 1
End If

End If
End If
End Sub
///

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:Oh**************@TK2MSFTNGP03.phx.gbl...
Hi Cor & all,

Core thanks for your response, I have a look on your web site, but I think
it may be a bit difficult if I want to use it for a text box - after I
think again what I really want - if it's possible I want to create a
function, with a papramater, then check whether it's a valid character,
i.e. in this case ":" & number are valid, if not cancel the character
entered, or replace with other character....um... that sounds good to me
but if you guys have a better advice please tell me!! So now the problem
I have is how to capture the character just entered....

Kay

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
>Kay,

Here is an autocomplete sample for a combobox, in my idea are all the
ingredients in that to make what you want. (It begins with building a
sample).

http://www.vb-tips.com/dbPages.aspx?...f-c22411591992

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:%2******************@TK2MSFTNGP05.phx.gbl. ..
>>Hi All,

I'm trying to write a small sub/function to replace some (invalid)
character
in a combo box, or may be even text box. For example, I have several
combo
boxes that allows user to select a time value, i.e. 21:30, however I
also
want to allow them to enter a time, as a result I want to replace comma,
fullstop etc with a colon ":". I've done this in VB6 keypress event,
however with the "sender", "e" in .net I'm a bit lost... I don't have
much
experience in .net could you guys give me some help?

Thanks!

Kay



Aug 22 '06 #4

P: n/a
Kay
Hi Cor,

Thanks for your help! Can I ask one more question? :P

Is there something like an ASCII table that represent a KeyValue? Coz I
want to capture more characters other than numbers. Tried to search through
the help but it didn't tell much.... may be I'm looking at the wrong
direction...

Kay
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:u7**************@TK2MSFTNGP02.phx.gbl...
Kay,

Have a look at the thenthousand samples about a numeric textbox on
Internet by using Google.

I have not set this one on our site, because there is nothing in it for
pushing the del key etc.
Especially for your question, use the keyup event most people want to use
the key down, which gives less information in the KeyEventArgs.

\\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.MaxLength = 10
End Sub
Private Sub textbox1_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles textbox1.KeyUp
If e.KeyValue <8 Then
If Not IsNumeric(TextBox1.Text) Then
If TextBox1.Text.Length 0 Then
MessageBox.Show("Only numeric is allowed")

TextBox1.SelectionStart = TextBox1.Text.Length - 1
TextBox1.SelectionLength = 1
End If

End If
End If
End Sub
///

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:Oh**************@TK2MSFTNGP03.phx.gbl...
>Hi Cor & all,

Core thanks for your response, I have a look on your web site, but I
think it may be a bit difficult if I want to use it for a text box -
after I think again what I really want - if it's possible I want to
create a function, with a papramater, then check whether it's a valid
character, i.e. in this case ":" & number are valid, if not cancel the
character entered, or replace with other character....um... that sounds
good to me but if you guys have a better advice please tell me!! So now
the problem I have is how to capture the character just entered....

Kay

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
>>Kay,

Here is an autocomplete sample for a combobox, in my idea are all the
ingredients in that to make what you want. (It begins with building a
sample).

http://www.vb-tips.com/dbPages.aspx?...f-c22411591992

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:%2******************@TK2MSFTNGP05.phx.gbl.. .
Hi All,

I'm trying to write a small sub/function to replace some (invalid)
character
in a combo box, or may be even text box. For example, I have several
combo
boxes that allows user to select a time value, i.e. 21:30, however I
also
want to allow them to enter a time, as a result I want to replace
comma,
fullstop etc with a colon ":". I've done this in VB6 keypress event,
however with the "sender", "e" in .net I'm a bit lost... I don't have
much
experience in .net could you guys give me some help?

Thanks!

Kay





Aug 23 '06 #5

P: n/a
Kay,

No I thought you know that, you see in the latest sample the 8 but there are
more therefore I said it was not complete.

Therefore I said have a look for a numeric textbox

This is a nice solution with the control characters
http://groups.google.com/group/micro...f7a8450e71ebf6

I took from Internet the first table I could find. I know that there is a
nicer one on MSDN, but with the same search information I could not find it
there, maybe you can try that yourself.

http://www.lookuptables.com/

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:uA**************@TK2MSFTNGP02.phx.gbl...
Hi Cor,

Thanks for your help! Can I ask one more question? :P

Is there something like an ASCII table that represent a KeyValue? Coz I
want to capture more characters other than numbers. Tried to search
through the help but it didn't tell much.... may be I'm looking at the
wrong direction...

Kay
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:u7**************@TK2MSFTNGP02.phx.gbl...
>Kay,

Have a look at the thenthousand samples about a numeric textbox on
Internet by using Google.

I have not set this one on our site, because there is nothing in it for
pushing the del key etc.
Especially for your question, use the keyup event most people want to use
the key down, which gives less information in the KeyEventArgs.

\\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.MaxLength = 10
End Sub
Private Sub textbox1_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles textbox1.KeyUp
If e.KeyValue <8 Then
If Not IsNumeric(TextBox1.Text) Then
If TextBox1.Text.Length 0 Then
MessageBox.Show("Only numeric is allowed")

TextBox1.SelectionStart = TextBox1.Text.Length - 1
TextBox1.SelectionLength = 1
End If

End If
End If
End Sub
///

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:Oh**************@TK2MSFTNGP03.phx.gbl...
>>Hi Cor & all,

Core thanks for your response, I have a look on your web site, but I
think it may be a bit difficult if I want to use it for a text box -
after I think again what I really want - if it's possible I want to
create a function, with a papramater, then check whether it's a valid
character, i.e. in this case ":" & number are valid, if not cancel the
character entered, or replace with other character....um... that sounds
good to me but if you guys have a better advice please tell me!! So now
the problem I have is how to capture the character just entered....

Kay

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
Kay,

Here is an autocomplete sample for a combobox, in my idea are all the
ingredients in that to make what you want. (It begins with building a
sample).

http://www.vb-tips.com/dbPages.aspx?...f-c22411591992

I hope this helps,

Cor

"Kay" <kk@kk.com.kkschreef in bericht
news:%2******************@TK2MSFTNGP05.phx.gbl. ..
Hi All,
>
I'm trying to write a small sub/function to replace some (invalid)
character
in a combo box, or may be even text box. For example, I have several
combo
boxes that allows user to select a time value, i.e. 21:30, however I
also
want to allow them to enter a time, as a result I want to replace
comma,
fullstop etc with a colon ":". I've done this in VB6 keypress event,
however with the "sender", "e" in .net I'm a bit lost... I don't have
much
experience in .net could you guys give me some help?
>
Thanks!
>
Kay
>
>
>




Aug 23 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.