|
| Autor |
Nachricht |
Fuka_ Coder


Anmeldedatum: 15.11.2007 Beiträge: 96
|
Ein "\" aus einem Pfad entnehmen
Verfasst am: 29.04.2008, 13:10 |
|
|
Moin Leute!
Vorwort:
Dank ZiG's Funktion aus Thread http://dbhost.info/vbx/viewtopic.php?t=2848 hier, ist es mir möglich aus z.B. "C:\Ordner1\Ordner2" -> "C:\Ordner1\" zu machen.
| Code: | Private Function GetPreviousDirectory(ByVal sFilepath As String) As String
On Error GoTo Err:
Dim iPos As Long
If Len(sFilepath) = 3 Then GoTo Err:
iPos = InStrRev(sFilepath, "\", Len(sFilepath) - 1)
If iPos = 0 Then GoTo Err:
GetPreviousDirectory = Mid$(sFilepath, 1, iPos)
Exit Function
Err:
GetPreviousDirectory = sFilepath
End Function |
Das brauch ich ja um in meinem RAT einen Ordner im Filemanager zurück zu gehen.
Frage:
Also.. Aus "C:\Ordner1\Ordner2" wird "C:\Ordner1\".
Es soll aber "C:\Ordner1" heißen, ohne das letze "\" !
Womit mache ich das aber? In der Funktion lässt sich das ja ändern, nur ich weiß nicht genau wie.
MfG |
|
| |
|
 |
ZiG_ Überflieger

Anmeldedatum: 07.03.2007 Beiträge: 1248
|
Verfasst am: 29.04.2008, 13:15 |
|
|
| Zitat: |
Private Function GetPreviousDirectory(ByVal sFilepath As String) As String
On Error GoTo Err:
Dim iPos As Long
If Len(sFilepath) = 3 Then GoTo Err:
iPos = InStrRev(sFilepath, "\", Len(sFilepath) - 1)
If iPos = 0 Then GoTo Err:
GetPreviousDirectory = Mid$(sFilepath, 1, iPos - 1)
Exit Function
Err:
GetPreviousDirectory = sFilepath
End Function
|
Wer nicht auf seine Weise denkt, denkt überhaupt nicht. (Oscar Wilde) |
|
| |
|
 |
Fuka_ Coder


Anmeldedatum: 15.11.2007 Beiträge: 96
|
Verfasst am: 29.04.2008, 13:40 |
|
|
Ach da!
Joa geht, nur wenn jetzt "C:\" steht, macht er daraus "C:". |
|
| |
|
 |
ZiG_ Überflieger

Anmeldedatum: 07.03.2007 Beiträge: 1248
|
Verfasst am: 29.04.2008, 13:58 |
|
|
Ja Mensch, was erwartest du denn?
Dann mußt du es dir so ändern das es voll und ganz deinen Wünschen entspricht.
Ich kann mich nur nach deinen Fragen und Erklärungen richten.
| Code: |
Private Function GetPreviousDirectory(ByVal sFilepath As String) As String
On Error GoTo Err:
Dim iPos As Long
If Len(sFilepath) = 3 Then GoTo Err:
iPos = InStrRev(sFilepath, "\", Len(sFilepath) - 1)
If iPos = 0 Then GoTo Err:
if iPos > 3 then
GetPreviousDirectory = Mid$(sFilepath, 1, iPos - 1)
Else
GetPreviousDirectory = Mid$(sFilepath, 1, iPos)
end if
Exit Function
Err:
GetPreviousDirectory = sFilepath
End Function
|
Wer nicht auf seine Weise denkt, denkt überhaupt nicht. (Oscar Wilde) |
|
| |
|
 |
dcm_ Newbie

Anmeldedatum: 24.02.2008 Beiträge: 15
|
Verfasst am: 29.04.2008, 14:11 |
|
|
Oder versuch doch einfach mal, was selber zu lösen, wie wärs damit? ^^
du hättest auch einfach abfragen können, ob der letzte buchstabe des strings ein ":" ist, und wenn ja ein "\" anhängen können... oder eben durch die länge |
|
| |
|
 |
Fuka_ Coder


Anmeldedatum: 15.11.2007 Beiträge: 96
|
Verfasst am: 29.04.2008, 14:11 |
|
|
Danke!!!
Ja ich bin nur grade echt nicht drauf gekommen
manchmal hat man so eine art "blackout"  |
|
| |
|
 |
|
|