|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Replace a character in combo boxHi 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 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?ID=aaf8f7e5-d5e8-4532-980f-c22411591992 I hope this helps, Cor Show quoteHide quote "Kay" <k*@kk.com.kk> schreef in bericht news:%23OH%23IqZxGHA.1284@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 > > > 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OxaogjaxGHA.5064@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?ID=aaf8f7e5-d5e8-4532-980f-c22411591992 > > I hope this helps, > > Cor > > "Kay" <k*@kk.com.kk> schreef in bericht > news:%23OH%23IqZxGHA.1284@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 >> >> >> > > 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 Show quoteHide quote "Kay" <k*@kk.com.kk> schreef in bericht news:OhDRUKbxGHA.4416@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]" <notmyfirstn***@planet.nl> wrote in message > news:OxaogjaxGHA.5064@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?ID=aaf8f7e5-d5e8-4532-980f-c22411591992 >> >> I hope this helps, >> >> Cor >> >> "Kay" <k*@kk.com.kk> schreef in bericht >> news:%23OH%23IqZxGHA.1284@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 >>> >>> >>> >> >> > > 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 Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:u7No3NbxGHA.4444@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" <k*@kk.com.kk> schreef in bericht > news:OhDRUKbxGHA.4416@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]" <notmyfirstn***@planet.nl> wrote in message >> news:OxaogjaxGHA.5064@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?ID=aaf8f7e5-d5e8-4532-980f-c22411591992 >>> >>> I hope this helps, >>> >>> Cor >>> >>> "Kay" <k*@kk.com.kk> schreef in bericht >>> news:%23OH%23IqZxGHA.1284@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 >>>> >>>> >>>> >>> >>> >> >> > > 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/microsoft.public.dotnet.languages.vb/msg/6ff7a8450e71ebf6 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 Show quoteHide quote "Kay" <k*@kk.com.kk> schreef in bericht news:uADeVnmxGHA.4660@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]" <notmyfirstn***@planet.nl> wrote in message > news:u7No3NbxGHA.4444@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" <k*@kk.com.kk> schreef in bericht >> news:OhDRUKbxGHA.4416@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]" <notmyfirstn***@planet.nl> wrote in message >>> news:OxaogjaxGHA.5064@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?ID=aaf8f7e5-d5e8-4532-980f-c22411591992 >>>> >>>> I hope this helps, >>>> >>>> Cor >>>> >>>> "Kay" <k*@kk.com.kk> schreef in bericht >>>> news:%23OH%23IqZxGHA.1284@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 >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > |
|||||||||||||||||||||||