Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7002895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:59:20+00:00 2026-05-27T20:59:20+00:00

PixPath is the full path to a folder of jpg’s, and I’m using code

  • 0

PixPath is the full path to a folder of jpg’s, and I’m using code like the following to process each jpg.

fileName = Dir(PixPath)
Do Until fileName = ""
   If Right$(fileName, 4) = ".jpg" Then   
      fileName = Dir()

      <process this jpg>

   End If
Loop

This works fine except the files are returned in alpha-numeric order, and not the order that the files are shown listed in the folder. Is there any way around this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:59:21+00:00Added an answer on May 27, 2026 at 8:59 pm

    You can’t do this with Dir.

    An alternative is to:

    • Use FileSystemObject to access all the files in your directory
    • Read in all the .jpg files into an array X
    • Use Val to compare the .jpgs by value to sort in a numeric ascending order
    • The final array X contains the sorted files

      Sub Test()
      Dim objFSO As Object
      Dim objFolder As Object
      Dim objFiles As Object
      Dim objFile As Object
      Dim X
      Dim lngFileCnt As Long
      Dim lngCnt As Long
      Dim i As Long
      Dim j As Long
      Dim strBuffer1 As String
      Dim strFolder As String
      
      Set objFSO = CreateObject("Scripting.fileSystemObject")
      strFolder = "C:\temp"
      Set objFolder = objFSO.getFolder(strFolder)
      Set objFiles = objFolder.Files
      lngFileCnt = objFiles.Count
      ReDim X(1 To lngFileCnt)
      
      'grab all jpg files        
      For Each objFile In objFiles
          If Right$(objFile.Name, 3) = "jpg" Then
              lngCnt = lngCnt + 1
              X(lngCnt) = objFile.Name
          End If
      Next
      
      'resize array to number of jpg files
      ReDim Preserve X(1 To lngCnt)
      
      'sort array by numeric value
      For i = 1 To lngCnt
          For j = (i + 1) To lngCnt
              If Val(X(i)) > Val(X(j)) Then
                  strBuffer1 = X(j)
                  X(j) = X(i)
                  X(i) = strBuffer1
              End If
          Next
      Next
      MsgBox Join(X, ";")
      End Sub
      

      See here for more info on using FileSystemObject.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a nifty little function: def startProcess(name, path): Starts a process in
I'm looking to get an image of a Visio page into the clipboard using
i am using rpy2-2.0.7 (i need this to work with windows 7, and compiling
So, I tried using this query: SELECT name, pID, fname, lname, picpath, email FROM
I am trying to create a simple and animated pie chart using CAShapeLayer .
String picPath = /mnt/sdcard/yepcolor/sina.png; Bitmap bitmap = BitmapFactory.decodeFile(picPath); I know the 'picPath' of the
How do I change desktop wallpaper? I tried this procedure TForm1.Button1Click(Sender: TObject); var PicPath:
I have an ASPX (PictureGetter.aspx) That loads images and writes them to the response
I have a base class that does calculations on image sizes. I'm deriving a
I just completed a fresh install of Ubuntu 10.10 and I'm trying to run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.