Results 1 to 3 of 3

Thread: WHat data type to use allow user only put number and string..

  1. #1

    Thread Starter
    Junior Member hunter2's Avatar
    Join Date
    Jun 2003
    Posts
    19

    WHat data type to use allow user only put number and string..

    Hey all..

    Just a question that...what kind of data type that only allow user put only number and string in textbox..I ask this cuz.. I want to make a text box that allow user put a number for ex like this :

    "15.7 In"
    then after click on button convert it will convert to "cm" show up on the label..

    but when i use data type string..user still can't put some thing that i don't repect likes this: "sfgfsfgsfgs in"

    So how can we fix them..

    and by the way..how can we use funtion right() to catch 2 last string on textbox ... I try it..but it had error..If some one has a sample code for this convertion...will be must appreciated..

    Plz help..

    Thanks


  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    VB Code:
    1. Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    2.  
    3.         Select Case e.KeyChar
    4.             Case "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "i", "n", " ", "."
    5.                 e.Handled = False '/// allow these.
    6.             Case Else
    7.                 e.Handled = True '/// stop all other chars.
    8.         End Select
    9.  
    10.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Or you can validate with IsNumber & IsLetter functions .

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