Results 1 to 3 of 3

Thread: [RESOLVED] VB2008 erase all but numbers

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2009
    Posts
    127

    Resolved [RESOLVED] VB2008 erase all but numbers

    My program uses OCR dll to get text from other program. It copy and paste text to a text box. Can someone give me a code that will erase everything exept numbers or "." from a text box? Thank you for help!

  2. #2
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: VB2008 erase all but numbers

    We could give you the code, but why? This forum is for teaching and learning. If you want the entire code you can offer some money and then you might get it, otherwise why would someone else want you to take credit for their work?

    If you want to actually learn we can help you, but we need to see what you've tried.

    That aside, something like this would be very easy and would just involve looping through the string letter by letter and adding any characters 0-9 and . onto another string.
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

  3. #3
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: VB2008 erase all but numbers

    Don't loop, use RegEx.

    Code:
    Dim sTest As String = "abc13def.190gh"
    MessageBox.Show(Regex.Replace(sTest, "[^\d\.]", String.Empty))
    You'll have to use Imports System.Text.RegularExpressions at the top of your code.

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