Find a null character in a string of filenames

Hi
I am using the common dialog control to open images. If there is a list of images this works fine using

 With frmtools.cdg_main
        .InitDir = initpath  'set the initial path
        .filename = ""  'rest the file name
        .Filter = "TIFF(.tif.TIF) *.tif|*.tif;|Windows Bitmap *.bmp| *.bmp;|Jpeg (.jpg,JPEG)*.jpg |*.jpg;|JPG 2000 (.jp2,jpf) *.jp2| *.jp2|" 'filter selection for available image types
        .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer  ' enable multiselect
        .CancelError = True 'set the cancel error
        .ShowOpen  'display the open dialog
        filname = .filename
    End With
   


 ' Each file are separated by a null char( chr$(0)  )
 
   filearray = Split(filname, Chr$(0))
       
    ' display the list of the selected files

    For i = LBound(filearray) + 1 To UBound(filearray)
   
        ' the first element is the path
        ' the others are the file name
       
        new_filepath = filearray(0) & "\" & filearray(i)
        ret = IpWsLoad(new_filepath, "")
       
    Next
   
   frmtools.cdg_main.Flags = 0 'reset the file open command

But if there is only one image it does nothing. As this is separated by a null char how can i tell if this char exists to tell if there is more tahn one file name. This does return the single finename so if i can tell between the two i can execute the different code

Thanks
eneateAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

danaseamanCommented:
Try this:

Private Sub Command1_Click()
   Dim fName            As String
   Dim fPath            As String
   Dim fArray()         As String
   Dim i                As Long

   With frmTools.cdg_main
      .InitDir = App.Path 'initpath  'set the initial path
      .FileName = ""  'rest the file name
      .Filter = "TIFF(.tif.TIF) *.tif|*.tif;|Windows Bitmap *.bmp| *.bmp;|Jpeg (.jpg,JPEG)*.jpg |*.jpg;|JPG 2000 (.jp2,jpf) *.jp2| *.jp2|" 'filter selection for available image types
      .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer  ' enable multiselect
      .CancelError = True 'set the cancel error
      .ShowOpen  'display the open dialog
      fName = .FileName
   End With

   ' Each file are separated by a null char( chr$(0)  )

   fArray = Split(fName, Chr$(0))

   ' display the list of the selected files
   If UBound(fArray) = 0 Then
      fPath = fArray(0)
      Debug.Print fPath
   Else
      For i = LBound(fArray) + 1 To UBound(fArray)
         ' the first element is the path
         ' the others are the file name
         fPath = fArray(0) & "\" & fArray(i)
         Debug.Print fPath
         'ret = IpWsLoad(fPath, "")
      Next
   End If
   frmTools.cdg_main.Flags = 0 'reset the file open command
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eneateAuthor Commented:
Thanks, works perfectly
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.