Results 1 to 4 of 4

Thread: Left function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    US
    Posts
    20

    Post

    In my program I have strings like " 49 49 13 49 23 49" without the quotes and I use Trim to take away spaces then Left to take the first two numbers but how can I "cut" the numbers out of the string?

    Andy

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    try using

    MyString = Right(MyString, Len(MyString) - 2)

    This works my taking the original MyString minus 2 characters and placing it back in MyString. There is probably a "better" way of doing it, but it works fine for me.

    Regards,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    you can extract the numbers into an array using the VB6 split function:
    Code:
        Dim strTemp As String
        Dim strArray() As String
        Dim I As Integer
        
        strTemp = " 49 49 13 49 23 49"
        
        strArray() = Split(strTemp, " ")
        
        For I = LBound(strArray) To UBound(strArray)
            Debug.Print strArray(I)
        Next I

  4. #4
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    or you can do this
    Code:
    Dim I
    Dim H
    
    H + Text1.text
    I = Mid(H,1,1)
    
    Text2.text = I

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