get directory name from a path using split

I am trying to get the full path to a directory based on a combo box selection
typical file path in array:
C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Williams 1247 RiverBend rd\Fencing Bids

Private Sub Command3_Click()
Dim FileName As String
If cboBids.ListIndex <> -1 Then
FileName = GetPathToCboItem(cboBids.Text)
End If
I keep getting a type mismatch
Function GetPathToCboItem(cboName As String) As String
Dim i As Integer
Dim strParts() As String
For i = LBound(mArrProjects) To UBound(mArrProjects)
    strParts = Split(mArrProjects(i), "\")
    If UBound(strParts) = cboName Then ' [b]type mismatch here[/b]
      GetPathToCboItem = mArrProjects(i)
      Exit Function
    End If
 Next
End Function

Open in new window

what is wrong ?
isnoend2001Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Martin LissConnect With a Mentor Older than dirtCommented:
Wait... do this.

 If strParts(UBound(strParts)) = cboName Then
0
 
Martin LissOlder than dirtCommented:
Ubound returns the number of items in the array -1. You want to do something like
If strParts(i) = cboName then
0
 
Martin LissOlder than dirtCommented:
Is C:\Documents and Settings\All Users.WINDOWS\Documents\RoofCalculator\Williams 1247 RiverBend rd what you want to get?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
isnoend2001Author Commented:
Thanks Martin Lliss that fixes the problem
0
 
Martin LissOlder than dirtCommented:
You're welcome. Do you understand why it works?
0
 
isnoend2001Author Commented:
Thanks not sure you changed
 If UBound(strParts) = cboName Then ' type mismatch here
to
   If strParts(UBound(strParts)) = cboName Then
and that fixed the issue
0
All Courses

From novice to tech pro — start learning today.