473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Replace a character in combo box

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
5 1908
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul | last post by:
I have a form in c#. I want whenever a user presses return on a text box, combo box or numericupdown control the key press will be trapped and replaced with a tab character forcing the user to...
1
by: Billy N. Patton | last post by:
-------- Original Message -------- Subject: <string>.replace Date: Fri, 15 Oct 2004 11:07:19 -0500 From: Billy N. Patton <b-patton@ti.com> Organization: Texas Instruments Newsgroups:...
3
by: ILCSP | last post by:
Heello, I'm using Access 2000. I have a form with a combo box that has a query as its row source and it's bound to column 1. This combo box is unbound to a record like the rest of the form...
14
by: Etu | last post by:
Hi, I have a string: string c = "'abc' \"cde\", 'mno' \"xyz\","; how can I use the c.Replace(???, ???) method to have this string: "'abc' "cde", 'mno' "xyz"," that is, all the...
18
by: james | last post by:
Hi, I am loading a CSV file ( Comma Seperated Value) into a Richtext box. I have a routine that splits the data up when it hits the "," and then copies the results into a listbox. The data also...
8
by: Warren Moxley | last post by:
Hi there, i've been searching for a C String search and replace function. I need to find all occurrences of " " in a char* array, and replace them with another char, I know how to do this in...
5
by: herman | last post by:
How can I replace all occurrences of a character with another character in std string? For example, I want to replace '/' with '+' in my std::string I have looked at the replace() method in...
10
by: Lonifasiko | last post by:
Hi, Just want to replace character at index 1 of a string with another character. Just want to replace character at that position. I thought Replace method would be overloaded with an index...
6
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello, I have some XML that is returned to my application from another vendor that I cannot change before it gets to me. I can only alter it after it gets to my application. That being said, I...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.