none
how to remove commas in name textbox if user have entered any? RRS feed

All replies

  • please help!!

    Use the Replace method of the string class.  Replace the comma with an empty string ("").

    https://msdn.microsoft.com/en-us/library/fk49wtc1%28v=vs.110%29.aspx

    • Proposed as answer by Frank L. Smith Thursday, March 9, 2017 12:55 PM
    Thursday, March 9, 2017 6:59 AM
  • You can remove but you can also avoid, 

    I just put a sample for that on our website. 

    Be aware this is to prevent there is keyed in anything other than numeric characters, you can tailor it to your own wish. 

    http://www.vb-tips.com/WindowsFormsNumericTextBox.ASPX


    Success
    Cor

    • Proposed as answer by Frank L. Smith Thursday, March 9, 2017 12:55 PM
    Thursday, March 9, 2017 7:40 AM
  • Hello,

    Don't allow them

    Private _NotAllowedCharacters As String = ","
    Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
        If _NotAllowedCharacters.Contains(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by Frank L. Smith Thursday, March 9, 2017 12:55 PM
    Thursday, March 9, 2017 11:50 AM
    Moderator
  • Hello,

    Don't allow them

    Private _NotAllowedCharacters As String = ","
    Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
        If _NotAllowedCharacters.Contains(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub

    Yes I was thinking about this, this morning. 

    When somebody in a Microsoft forum asks 

    "How can I kill the best my wife", then:

    1. Most normal persons tell "I suggest you not to do that"
    2. A long time MVP tells "Better not to ask this in a forum"

    And then when everybody has given this kind of answers a moderator gives the final advice.

    "I advice not to take a knife, but use a gun"


    Why would somebody only want to remove a comma in a string with only special characters?


    Success
    Cor



    Thursday, March 9, 2017 12:05 PM
  • Why would somebody only want to remove a comma in a string with only special characters?

    The most common reason is that the string is going to be joined to others in a line of comma-separated values.

    Thursday, March 9, 2017 8:14 PM
  • Why would somebody only want to remove a comma in a string with only special characters?

    The most common reason is that the string is going to be joined to others in a line of comma-separated values.

    I'm without words.

    Success
    Cor

    Thursday, March 9, 2017 10:40 PM