Results 1 to 12 of 12

Thread: Textbox Edit Mask

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68

    Textbox Edit Mask

    I have a textbox used to enter date, and I would like to use and edit mask __/__/____ so user don't have to enter "/"


    Idem for numerix textbox, is there a method to allow only numeric value inside textbox ?


    and last one an edit mask which put all in lower case exept the first letter in uppercase.

    duPOnt => Dupont


    Thanks

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This allows only numeric values .
    VB Code:
    1. Dim KeyAscii As Integer
    2.         KeyAscii = Asc(e.KeyChar)
    3.  
    4.         Select Case KeyAscii
    5.             Case Asc("0") To Asc("9")
    6.  
    7.                 e.Handled = False
    8.             Case Else
    9.                 e.Handled = True
    10.         End Select

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Put that code into keypress event of the specified textbox .

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68
    Thanks

  5. #5
    New Member
    Join Date
    Jun 2003
    Posts
    4

    Textbox Edit Mask

    The textbox object has a property called CharacterCasing which you can set to force all characters to lower case.
    "Convenience is not"

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by skaterx2
    The textbox object has a property called CharacterCasing which you can set to force all characters to lower case.
    This does the same .
    VB Code:
    1. TextBox1.Text = StrConv(str, VbStrConv.LowerCase)

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68
    And to put only the first caractere in uppercase :

    aPpLe = Apple ???


  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. TextBox1.Text = StrConv(str, VbStrConv.ProperCase)

  9. #9

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68
    Thanks but it change the first letter of all words in the textbox

    What I would like is to change only the first Letter of the first word.


    I thinks I'll need to create a small function for that.

    Do I need to create a class when I create a function that can be used by all my forms ?

    What could be the code ?


    Thanks to all for your support, I'll finish my application this WE.

    It's great to find peoples who are sharing their knowledge

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You don't need to create new class , just paste the code below in a module file then you can call it from anywhere within your project .


    VB Code:
    1. Public Function MyFunction(ByVal ProcessStr As String) As String
    2. Dim CaptL As String = UCase(RSet(ProcessStr, 1))
    3. Dim ResultStr As String
    4.  
    5. ResultStr = CaptL + ProcessStr.Remove(0, 1)
    6. Return ResultStr.ToString
    7. End Function

    Usage (one way like this ) :

    VB Code:
    1. MessageBox.Show(MyFunction(TextBox1.Text))

  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 2003
    Posts
    68
    Great you are the best

  12. #12
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    why not use the DateTimePicker?
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width