Results 1 to 4 of 4

Thread: question

  1. #1
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80

    Unanswered: question

    I have created a "browse"-button, which opens up a file dialog, which stores the path to chosen file (picture file) in a text field, so that they can be viewed in report.

    The picture files are named like this: "class_firstname_lastname.jpg". How can I get the first name and last name from the filename to separate text fields (FirstName, LastName). Is it possible to get the "browse"-button to check the filename and insert the names to corresponding fields. I don't want to waste my time writing all the names myself.

  2. #2
    Join Date
    Oct 2003
    Location
    US
    Posts
    343

    Re: question

    If you have this "class_firstname_lastname.jpg" stored in a variable you can parse it. I can send you a simple code if thats what you want.

    Originally posted by Sham81
    I have created a "browse"-button, which opens up a file dialog, which stores the path to chosen file (picture file) in a text field, so that they can be viewed in report.

    The picture files are named like this: "class_firstname_lastname.jpg". How can I get the first name and last name from the filename to separate text fields (FirstName, LastName). Is it possible to get the "browse"-button to check the filename and insert the names to corresponding fields. I don't want to waste my time writing all the names myself.

  3. #3
    Join Date
    Oct 2003
    Location
    Finland
    Posts
    80
    That would be nice... Thanks

  4. #4
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    Public Function ParseString(inString As String, Delimiter As String) As Collection
    ' Purpose :To parse a String which is delimited.
    ' :The parsed pieces are stored in a user collection
    ' :which is then passed on to the calling procedure
    '

    Dim colParse As Collection
    Dim strAlpb As String
    Dim str As String
    Dim i As Integer

    On Error GoTo Local_Err

    Set colParse = New Collection

    For i = 1 To Len(inString)
    strAlpb = mid$(inString, i, 1)
    If strAlpb = Delimiter Then
    colParse.Add str
    str = ""
    Else
    str = str & strAlpb
    End If
    Next i
    Set ParseString_TEST = colParse

    Exit_Err:
    Exit Function

    Local_Err:
    Select Case Err.Number
    Case 3704 'Object already closed
    Resume Next
    Case Else
    MsgBox Err.Number & ": " & Err.DESCRIPTION, vbCritical, "Function:ParseString()"
    Resume Exit_Err
    End Select

    End Function

    Pass your string along with "-" delimiter (as in your case) to the above function using this function

    Public Sub test()
    Dim varItem As Variant
    Dim ColMe As Collection

    ' Set ColMe = ParseString("stringname","-")
    Set ColMe = ParseString
    For Each varItem In ColMe
    Debug.Print varItem
    Next varItem
    End Sub


    Originally posted by Sham81
    That would be nice... Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •