Results 1 to 3 of 3

Thread: that, uhh... function --- HELP!

  1. #1

    Thread Starter
    Member
    Join Date
    May 1999
    Location
    San Jose, CA, USA
    Posts
    43

    Angry

    hey, i can't remember the name of the function that would separate a string depending on a string like ",".. man, kinda hard to explain, someones gotta know tho.

    I basically need to get the directory out of a string like "C:\(blabla)\(blabla)\file.txt"... get it? so i'd have "C:\(blabla)\(blabla)"

    PLEASE HELP!!
    -_=Progrium=_-
    Progrium Software

    Using: VB 6 Pro

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Split?

    ...or use a function like this:
    Code:
    Function SplitCommand(Arg() As String, Text As String, Seperator As String) As Long
        Dim Length As Long
        
        Dim Count As Long
        Dim Pos As Long
        Dim Temp As Long
        
        Count = -1
        Pos = 1
        ReDim Arg(0)
        
        Length = Len(Text)
    
        While Pos <= Length
            Temp = InStr(Pos, Text, Seperator, vbTextCompare)
            
            If Temp = 0 Then
                Count = Count + 1
                ReDim Preserve Arg(Count)
                Arg(Count) = Mid(Text, Pos, Len(Text) - Pos + 1)
                Pos = Length + 1
                
            Else
                Count = Count + 1
                ReDim Preserve Arg(Count)
                Arg(Count) = Mid(Text, Pos, Temp - Pos)
                
                Pos = Temp + 1
            End If
        Wend
        
        GetArgsFast = Count
    End Function

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Ah
    I just read the question again.. well, here's one to get the path:
    Code:
    Function GetPath(iFile As String) As String
        Dim Temp As String * 1
        Dim A As Long
        
        'Return path of file
        For A = Len(iFile) To 1 Step -1
            Temp = Mid(iFile, A, 1)
            
            'Path found
            If Temp = "\" Or Temp = "/" Then
                GetPath = Left(iFile, A)
                
                Exit Function
            End If
        Next
    End Function

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