SplitPath (2)




Private Sub Command1_Click()
Dim i As Integer
Text2.Text = Text1.Text
Do
If InStr(1, Text2.Text, "\", vbTextCompare) <> 0 Then
Text2.Text = Mid(Text2.Text, 2, Len(Text2.Text))
Else
If InStr(1, Text2.Text, ".", vbTextCompare) <> 0 Then
i = InStr(1, Text2.Text, ".", vbTextCompare)
Text3.Text = Mid(Text2.Text, 1, i - 1)
Text6.Text = Mid(Text2.Text, i + 1, Len(Text2.Text))
Else
Text2.Text = Text2.Text
End If
GoTo here
End If
Loop
here:
Text5.Text = Mid(Text1.Text, 1, 3)
Text4.Text = Mid(Text1.Text, 1, Len(Text1.Text) - Len(Text2.Text))
End Sub

Private Sub Command2_Click()
On Error GoTo error
File1.ListIndex = Int(Rnd * File1.ListCount - 1)
Text1.Text = File1.Path & "\" & File1.FileName
Exit Sub
error:
MsgBox "Error Selecting Random File", vbCritical, "Error"
End Sub

Private Sub Form_Load()
Randomize
File1.Path = "C:\Windows\"
End Sub











( splitpath2.html )- by Paolo Puglisi - Modifica del 17/12/2023