Skip to main content

AccessTr.neT


Dizini bölme hakkında

Dizini bölme hakkında

Çözüldü #4
Function GetFileName(ByVal Path As String) As String
' Description: Given a file path, return the file name.
' Parameter: Path = Full folder path.
' Returns: "C:\MyFolder\Myfile.txt" returns Myfile.txt

'Create a dynamic array.
Dim sParts() As String

'Split the path into parts,
'using the backslash as a delimiter,
'filling the array's elements with the
'broken up string segments.
sParts = Split(Path, "\")

' At this point, the array
' named sParts would look
' something like the following:
' --------------------------------
' | 0 | 1 | 2 |
' --------------------------------
' | C: | MyFolder | MyFile.txt |
' --------------------------------

' In code you may refer to a specific
' element by its numbered position:

' sParts(0) = C:
' sParts(1) = MyFolder
' sParts(2) = MyFile.txt

' Or you can simply get the last element
' using the handy UBound function...
GetFileName = sParts(UBound(sParts))

End Function

Function GetDriveLetter(ByVal Text As String) _
As String
' Description: Given a file path, return the drive letter.
' Parameter: Text = Full file path.
' Returns: "C:\MyFolder\Myfile.txt" returns C:

' See the code comments in the GetFileName function above.
Dim sParts() As String
sParts = Split(Text, "\")
GetDriveLetter = sParts(LBound(sParts))

End Function

Function DoesItemExist(sList As String, _
sDelimiter As String, _
sItem As String) _
As Boolean
'Say your program receives or produces lists,
'lists that may look like this:
' beer-bread-peaches-yams

'Notice that the list has a character that separates
'-- or delimits -- the items, a hyphen.

'One more thing: say your list may or may not
'contain certain items. That is, say you only
'want to know if beer is in your list...

'Create a dynamic array.
Dim sItems() As String

'Put the list into the array.
sItems = Split(sList, sDelimiter)

'Move through each item in the array,
Dim i As Integer
For i = LBound(sItems) To UBound(sItems)
'searching for a specific item...
If sItems(i) = sItem Then
'Found it.
DoesItemExist = True
'We're done, so leave.
Exit For
End If
Next i

End Function

Açtığım konuda bu fonksiyonu yabancı bir kaynakta buldum. Bunun hakkında yardım alabilirmiyim
iterlemez, 18-07-2010 tarihinden beri AccessTr.neT üyesidir.
Son Düzenleme: 17/11/2010, 21:01, Düzenleyen: iterlemez.
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
Dizini bölme hakkında - Yazar: iterlemez - 17/11/2010, 19:08
Cvp: Dizini bölme hakkında - Yazar: ercansahin - 17/11/2010, 20:06
Cvp: Dizini bölme hakkında - Yazar: iterlemez - 17/11/2010, 20:13
Cvp: Dizini bölme hakkında - Yazar: iterlemez - 17/11/2010, 21:00
Cvp: Dizini bölme hakkında - Yazar: akd - 21/11/2010, 13:42
Cvp: Dizini bölme hakkında - Yazar: benremix - 05/12/2010, 09:33
Task