Results 1 to 5 of 5

Thread: String Variable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Posts
    71

    Question 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
    jim mcnamara
    Guest
    IF the string came from c it will be null-terminated - chr(0) is the last character.

    If you are using a byte array the last char is Ubound(arr() )

    IF you are staying in VB, then pass a dynamic string ByVal into the sub/function. VB code gives len(str).

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    It seems to me that you have a string that starts with numerals and continues for however long and becomes letters or something.

    This is a quote from the help file on the val keyword
    The Val function stops reading the string at the first character it can't recognize as part of a number. Symbols and characters that are often considered parts of numeric values, such as dollar signs and commas, are not recognized. However, the function recognizes the radix prefixes &O (for octal) and &H (for hexadecimal). Blanks, tabs, and linefeed characters are stripped from the argument.

    The following returns the value 1615198:

    Val(" 1615 198th Street N.E.")
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4
    Megatron
    Guest
    Use this function
    Code:
    Function GetNumCount(ByVal sString As String) As Long
        For i = 1 To Len(sString)
            If Mid(sString, i, 1) Like "#" Then GetNumCount = GetNumCount + 1
        Next i
    End Function
    Usage:
    Code:
    Print GetNumCount("kjgd8732jfdsk8343jf3")

  5. #5
    jim mcnamara
    Guest
    Interesting - I didn't get what he wanted - I thought he wanted the length of the string so he could search it. Duh.

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