Results 1 to 5 of 5

Thread: Only using the first characters entered in textbox..

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    England
    Posts
    270

    Only using the first characters entered in textbox..

    Hey,
    I'm working on a query where I only want to use the 8 first characters entered in to the textbox. Is there some attribute to textbox that allows me to do this?
    Thanks for your time.

  2. #2
    Addicted Member
    Join Date
    Apr 2009
    Location
    Croatia
    Posts
    201

    Re: Only using the first characters entered in textbox..

    you want to limit textbox characters to 8 max, or you need to parse first 8 characters from it?
    explain a bit more please

  3. #3
    Fanatic Member stlaural's Avatar
    Join Date
    Sep 2007
    Location
    Quebec, Canada
    Posts
    683

    Re: Only using the first characters entered in textbox..

    If you don't want to limit the textbox content size you can simply use substring
    vb.net Code:
    1. textbox1.text.substring(0,8)
    will return the first 8 characters of your textbox. Make sure that your textbox contains at least 8 characters before calling the substring if you don't want an exception to be thrown.
    Alex
    .NET developer
    "No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)

    Things to consider before posting.
    Don't forget to rate the posts if they helped and mark thread as resolved when they are.


    .Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
    My fresh new blog : writingthecode, even if I don't post much.

    System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    England
    Posts
    270

    Re: Only using the first characters entered in textbox..

    I need the user to be able to type into the textbox, for instance: "3334445554422",
    but I only want to use "33344455". I can't limit the textbox, because it's necessary for them to type in the whole number. I wish the was like a textbox1.text(limit=8) function..
    Thank you for replying!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Location
    England
    Posts
    270

    Re: Only using the first characters entered in textbox..

    Ah, okay! Thanks, stlaural!

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