473,812 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1940
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.kksc hreef in bericht
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
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******** ******@TK2MSFTN GP04.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.kksc hreef in bericht
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
>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(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.TextBox1.Max Length = 10
End Sub
Private Sub textbox1_KeyUp( ByVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) Handles textbox1.KeyUp
If e.KeyValue <8 Then
If Not IsNumeric(TextB ox1.Text) Then
If TextBox1.Text.L ength 0 Then
MessageBox.Show ("Only numeric is allowed")

TextBox1.Select ionStart = TextBox1.Text.L ength - 1
TextBox1.Select ionLength = 1
End If

End If
End If
End Sub
///

I hope this helps,

Cor

"Kay" <kk@kk.com.kksc hreef in bericht
news:Oh******** ******@TK2MSFTN GP03.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******** ******@TK2MSFTN GP04.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.kksc hreef in bericht
news:%2******* ***********@TK2 MSFTNGP05.phx.g bl...
>>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******** ******@TK2MSFTN GP02.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(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.TextBox1.Max Length = 10
End Sub
Private Sub textbox1_KeyUp( ByVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) Handles textbox1.KeyUp
If e.KeyValue <8 Then
If Not IsNumeric(TextB ox1.Text) Then
If TextBox1.Text.L ength 0 Then
MessageBox.Show ("Only numeric is allowed")

TextBox1.Select ionStart = TextBox1.Text.L ength - 1
TextBox1.Select ionLength = 1
End If

End If
End If
End Sub
///

I hope this helps,

Cor

"Kay" <kk@kk.com.kksc hreef in bericht
news:Oh******** ******@TK2MSFTN GP03.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******* *******@TK2MSFT NGP04.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.kksc hreef in bericht
news:%2****** ************@TK 2MSFTNGP05.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.kksc hreef in bericht
news:uA******** ******@TK2MSFTN GP02.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******** ******@TK2MSFTN GP02.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(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.TextBox1.Max Length = 10
End Sub
Private Sub textbox1_KeyUp( ByVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) Handles textbox1.KeyUp
If e.KeyValue <8 Then
If Not IsNumeric(TextB ox1.Text) Then
If TextBox1.Text.L ength 0 Then
MessageBox.Show ("Only numeric is allowed")

TextBox1.Select ionStart = TextBox1.Text.L ength - 1
TextBox1.Select ionLength = 1
End If

End If
End If
End Sub
///

I hope this helps,

Cor

"Kay" <kk@kk.com.kksc hreef in bericht
news:Oh******* *******@TK2MSFT NGP03.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****** ********@TK2MSF TNGP04.phx.gbl. ..
Kay,

Here is an autocomplete sample for a combobox, in my idea are all the
ingredient s 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.kksc hreef in bericht
news:%2***** *************@T K2MSFTNGP05.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
experienc e 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
1450
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 move to the next control. I can trap for the character but can only block the return and then do a sendkeys for tab. Surely there is a way to change the character that is trapped.
1
2198
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: alt.comp.lang.learn.c-c++ I'm trying to remove the \n from a string. If I just simply locate teh char and replace it with \0 then the destructor should only delete up to the \0 and leave 1 char unrecovered.
3
2187
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 fields. I get a number ID (12345) as the value when I choose it. I use code to save my record and I have no problem with that. The issue comes when I need to add a character (a letter B,M, or E, to the number selected in the combo box so instead of...
14
3283
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 backslashes are removed.
18
4639
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 has some different characters in it that I am trying to remove. The small a with two dots over it and the small y with two dots over it. Here is my code so far to remove the small y: Private Sub Button2_Click(ByVal sender As System.Object, ByVal...
8
22125
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 managed environments, but i'm still learning C, does anyone have a quicky function handy? or point me in the right direction on how to acccomplish this? your help is greatly appreciated. Also a note, this is running on a embedded device, so i can't...
5
25531
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 the string class, it does not replace all occurrences of a character with another character. http://www.cppreference.com/cppstring/index.html
10
18642
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 parameter with which you can write wanted character at that position. But no, Replace method only allows replacing one known character with another. The problem is I don't know the character to replace, just must replace the character at a known...
6
3100
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 am having a problem loading the XML correctly into my app. Here is the code: ==================================== Dim sPaymentXML as String
0
10404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9219
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7677
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.