Sub split1()
'Declaring the variables
Dim strString, strNewPath
strString = "c:\january\february\test.exe"
'This helps to capture any error if gets created.
On Error Resume Next
strString = split(strString, "\")
'Capture the Error message
If (Err.Number) Then
'MsgBox (Err.Description)
End If
'UBound - Returns the highest available subscript for the indicated dimension of an array.
'Navigating to each substring
For i = 0 To UBound(strString) - 1
'Print the each substring
MsgBox (strString(i))
strNewPath = strNewPath & strString(i) & "\"
'MsgBox ("While breaking the string:" & strNewPath)
Next
'MsgBox ("Without removing the string:" & strNewPath)
'Since we have appended "\", trying to take Left part of the string with the length Len(strNewPath) -1
strNewPath = Left(strNewPath, Len(strNewPath) - 1)
'MsgBox ("After removing the string:" & strNewPath)
End Sub
'Declaring the variables
Dim strString, strNewPath
strString = "c:\january\february\test.exe"
'This helps to capture any error if gets created.
On Error Resume Next
strString = split(strString, "\")
'Capture the Error message
If (Err.Number) Then
'MsgBox (Err.Description)
End If
'UBound - Returns the highest available subscript for the indicated dimension of an array.
'Navigating to each substring
For i = 0 To UBound(strString) - 1
'Print the each substring
MsgBox (strString(i))
strNewPath = strNewPath & strString(i) & "\"
'MsgBox ("While breaking the string:" & strNewPath)
Next
'MsgBox ("Without removing the string:" & strNewPath)
'Since we have appended "\", trying to take Left part of the string with the length Len(strNewPath) -1
strNewPath = Left(strNewPath, Len(strNewPath) - 1)
'MsgBox ("After removing the string:" & strNewPath)
End Sub
No comments:
Post a Comment