CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: String Variable

  1. #1
    Join Date
    Sep 2000
    Posts
    127

    String Variable

    I know that the 1st character of a unknown string variable is a number & the following characters are also numbers but do not know exactly how many following characters are numbers, so how can i exact only numbers from this string starting from the 1st character?


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: String Variable

    This leaves all the non numbers from a string

    dim strInput as string
    dim strResult as string

    strInput = "Th1s 15 a t35t 5tr1ng"

    for t=1 to len(mystring)
    if Isnumeric(mid(strInput,t,1)) then
    ' this is a number
    strResult = strResult & mid(strInput,t,1)
    end if
    next t
    ' after this loop, strresult should have the value 1153551




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Sep 2000
    Posts
    127

    Re: String Variable

    How can i delete the first 3 characters of a string?


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: String Variable

    be sure the string is > 2 char
    if len(mystr)> 2 then
    mystr= right(mystr,len(mystr)-3)
    end if

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured