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 8015339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:13:31+00:00 2026-06-04T20:13:31+00:00

I am trying to run this line of code: Dim OrderedFiles() As String =

  • 0

I am trying to run this line of code:

Dim OrderedFiles() As String = Directory.GetFiles(FilePath).OrderBy(x >= x.CreationTime)

I get an error on x saying x is not declared.

I have my project set to Option Strict Off and Option Infer On. If I turn ON Option Strict then I get thousands of errors from the project(it is inherited) and I don’t have the time to fix all of them, but x no longer gives me an error. I have googled until I want to throw my computer out the window.

Any help on how to correct this statement would be appreciated.

Edit:

I was hoping for a more elegant solution but here is what I came up with to solve this particular problem.

    Dim fileList() As String = Directory.GetFiles(FilePath)
    Dim fileDate(fileList.Length - 1) As DateTime

    For i As Integer = 0 To fileList.Length - 1
        fileDate(i) = New FileInfo(fileList(i)).CreationTime
    Next

    Array.Sort(fileDate, fileList)

    With EmailTemplates_DropDownList
        .DataSource = fileList.Reverse.Take(5)
        .DataBind()
    End With

It is not particularly elegant but it does the job. I was hoping for a one liner LINQ solution and I just don’t have the background in LINQ to know how to do the job, time to go buy a book.

  • 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-06-04T20:13:33+00:00Added an answer on June 4, 2026 at 8:13 pm

    I’m not sure where you got this syntax from:

    OrderBy(x >= x.CreationTime)
    

    That almost looks like the C# syntax of

    OrderBy(x => x.CreationTime)
    

    but I believe in VB you would use

    OrderBy(Function(x) x.CreationTime)
    

    That’s certainly what the example in Enumerable.OrderBy would suggest.

    EDIT: At that point you’ll get a different error, as per Steve’s post… but he hasn’t corrected the syntax. I suspect you want:

    Dim OrderedFiles() As FileInfo = new DirectoryInfo(FilePath).GetFiles(). 
                                            OrderBy(Function(x) x.CreationTime).
                                            ToArray()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run this line of code: Process p = Runtime.getRuntime().exec(new String[]
I get an exception on the List.Add line when trying to run this code:
So I'm trying to run this code... my $filePath = $ARGV['0']; if ($filePath eq
When im trying to run this code to establish a connection ...... this error
I'm trying to run this code: let coins = [50, 25, 10, 5, 2,1]
I am trying to run this code: ItemTaxonomy iTaxonomy = from itemTaxonomy in connection.ItemTaxonomy
I am trying to run this seemingly simple piece of code which is repeated
I am trying to run this code : exec myStoredProcedure Cast('c5b48202-36af-4597-9780-5366d4188f55' AS uniqueidentifier), 744,
Im trying to run this code . Basically I want the https://admin:qwerty123@ '$dmp':7777/set_param?'$params command
I'm trying to run this code on Oracle 11g and it's giving me the

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.