pdf文件名按文件夹顺序打印 [英] pdf file name print in Folder Order

查看:356
本文介绍了pdf文件名按文件夹顺序打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我的文件夹中有很多pdf文件.我需要在文本文件中打印pdf文件名.打印文件名后,我正在使用VB6代码,但顺序不正确.

文件夹中的文件

CR 6.1.09.pdf
CR 9.1.09.pdf
CR 13.08.08.pdf
CR 14.1.09.pdf
CR 16.01.09.pdf
CR转换为GB.pdf
电子邮件21.09.07.1.pdf
硬件说明4.02.09.pdf
Ledger.pdf
MC 30.10.08.pdf
SH字母10.3.09.pdf

按如下所示打印文件名之后

CR 13.08.08.pdf
CR 14.1.09.pdf
CR 16.01.09.pdf
CR 6.1.09.pdf
CR 9.1.09.pdf
CR转换为GB.pdf
电子邮件21.09.07.1.pdf
硬件说明4.02.09.pdf
Ledger.pdf
MC 30.10.08.pdf
SH字母10.3.09.pdf

我需要按文件夹顺序打印文件名.希望清除

任何人都发送正确的代码.

谢谢

Hello Friends,

i have lot of pdf files in folder. i need to print the pdf file names in text file. i am using VB6 code after print the file names i am not get in proper order.

Files in Folder

CR 6.1.09.pdf
CR 9.1.09.pdf
CR 13.08.08.pdf
CR 14.1.09.pdf
CR 16.01.09.pdf
CR to GB.pdf
Email 21.09.07.1.pdf
HW notes 4.02.09.pdf
Ledger.pdf
MC 30.10.08.pdf
SH letter10.3.09.pdf

After printing the files name as below

CR 13.08.08.pdf
CR 14.1.09.pdf
CR 16.01.09.pdf
CR 6.1.09.pdf
CR 9.1.09.pdf
CR to GB.pdf
Email 21.09.07.1.pdf
HW notes 4.02.09.pdf
Ledger.pdf
MC 30.10.08.pdf
SH letter10.3.09.pdf

i need to print the file name in folder order. Hope clear

any one send the correct code.

Thanks

推荐答案

此函数将按字母数字顺序进行排序:
This function will sort alphanumerically:
Private Sub SortAlphaNum(List() As String)
    Dim TagedList() As String       ' List with "tags" in the numbers.
    ReDim taggedlist(UBound(List))

    Dim item As String              ' One item with tags.
    Dim ch As String                ' One character.
    Dim num As String               ' A number.  Can be multidigit.
    Dim digitCount As Integer       ' The number of digits.
    Dim i, j As Integer

    ' Visit each item in the list.
    For i = 0 To UBound(List) - 1
        ' Init.
        item = ""
        inNum = False
        num = ""
        digitCount = 0
        j = 1

        ' Examine each character.
        While j <= Len(List(i))
            ' Get one character.
            ch = Mid(List(i), j, 1)

            ' If the character is not a digit put it in the item.
            If ch < "0" Or ch > "9" Then
                item = item & ch

            ' Else, this is a digit.
            Else
                ' Keep reading digits.
                While ch >= "0" And ch <= "9"
                    ' Increase the count and add digit to num.
                    digitCount = digitCount + 1
                    num = num & ch
                    j = j + 1

                    ' Get another character.
                    ch = Mid(List(i), j, 1)
                Wend

                ' Add the tag and digit to the item.
                item = item & digitCount
                item = item & num

                ' If this is not the end of the line, add the last character read to the item.
                If j <= Len(List(i)) Then
                    item = item & ch
                End If
            End If
            j = j + 1
        Wend
        ' update the tagged list with the item.
        taggedlist(i) = item
    Next i

    ' Sort the tagged list (along with the real list).
    ' This is just a bubble sort.  Probably should replace.
    For i = 0 To UBound(taggedlist) - 2
        For j = 0 To UBound(taggedlist) - 2
            If taggedlist(j) > taggedlist(j + 1) Then
                item = taggedlist(j)
                taggedlist(j) = taggedlist(j + 1)
                taggedlist(j + 1) = item
                item = List(j)
                List(j) = List(j + 1)
                List(j + 1) = item
            End If
        Next j
    Next i
End Sub




要使用类似这样的名称:




To call it use something like this:

Private Sub Command1_Click()
    Dim i As Integer
    Dim mylist() As String
    ReDim mylist(List1.ListCount)

    ' Get list from listbox1.
    For i = 0 To List1.ListCount - 1
        mylist(i) = List1.List(i)
    Next i

    ' Sort the list.
    Call SortAlphaNum(mylist)

    ' Display in listbox2.
    List2.Clear
    For i = 0 To List1.ListCount
        Call List2.AddItem(mylist(i))
    Next i
End Sub



通过在数字组前面放置标签"进行排序.例如:两个文件
CR 9.1.09.pdf
CR 13.08.08.pdf
将被标记为
CR 1 9. 1 1. 2 09.pdf
CR 2 13. 2 08. 2 08.pdf
现在可以正常对其进行排序,然后使用原始列表重新显示.
我已经做出了一个假设(可能很糟糕),即所有数组都从0开始.



This sorts by putting a "tag" in front of digit groups. For example: the two files
CR 9.1.09.pdf
CR 13.08.08.pdf
will be tagged as
CR 19.11.209.pdf
CR 213.208.208.pdf
This can now be sorted normally and then redisplayed using the original list.
I have made the assumption (probably bad) that all arrays start at 0.


这篇关于pdf文件名按文件夹顺序打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆