VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



To create a folder hierarchy for the storage of files, I am presenting this algorithm. You should h

by Muhammad Musa Ali (6 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 20th November 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

To create a folder hierarchy for the storage of files, I am presenting this algorithm. You should have your file name as numeric one like

Rate To create a folder hierarchy for the storage of files, I am presenting this algorithm. You should h



'Purpose            : Returns the folder and sub folder for developing the path
'                     i.e. folder\SubFolder\FileName.tif
'Algorithm          : Recursively divide filename by 256 unless the quotient
'                     becomes less than 10. As a result of this division,
' the final quotient is the folder and the remainder is the SubFolder.
'Parameters         : input = file name; output= folder, subfolder

Function div(ByVal dblNum, dblFolder, dblSubFolder) As Boolean
Dim pos As Integer
Dim str1 As Double
Dim dblQuotient As Double
dblQuotient = dblNum / 256
If dblQuotient >= 1 Then
    pos = InStr(1, LTrim(Str(dblQuotient)), ".", vbTextCompare)
    If pos > 0 Then
        dblQuotient = Mid(LTrim(Str(dblQuotient)), 1, (pos - 1))
    End If
    If dblQuotient > 2560 Then
        div dblQuotient, dblFolder, dblSubFolder
    Else
        str1 = dblQuotient
        dblFolder = dblQuotient / 256
        If dblFolder >= 1 Then
            pos = InStr(1, LTrim(Str(dblFolder)), ".", vbTextCompare)
            If pos > 0 Then
            dblFolder = Mid(LTrim(Str(dblFolder)), 1, (pos - 1))
            Else
            dblFolder = dblFolder
            End If
            dblSubFolder = str1 Mod 256
        Else
           dblSubFolder = dblFolder * 256
            dblFolder = 0
        End If
    End If
Else
    dblFolder = 0
    dblSubFolder = 0
End If
div = True
End Function

Download this snippet    Add to My Saved Code

To create a folder hierarchy for the storage of files, I am presenting this algorithm. You should h Comments

No comments have been posted about To create a folder hierarchy for the storage of files, I am presenting this algorithm. You should h. Why not be the first to post a comment about To create a folder hierarchy for the storage of files, I am presenting this algorithm. You should h.

Post your comment

Subject:
Message:
0/1000 characters