Speed up my loops

Hi EE, I have a vb.net form that has 2 FOR Loops and inside the first loop i have a Query LINQ that get some information ....
bottom line... its really slow... it could take something like 45 minutes to compute everything....

I am not aware of new ways of coding that could speed up this. for example, i just learned about PLINQ but would that help me, i dont know..is there anything

my code is the follwing :

For x As Integer = 0 To last.Count - 1   (which is about 2415 loops)
      'MyItems has about 8900 items in it, its a dictionnary of Date, String

    'q will always ahve about between 600 to 700 items in it....
            Dim q = (From m In MyItems
                    Where arrString.All(Function(v) m.Value.Contains(v))
                    Select m)

            For y As Integer = 0 To q.Count - 1
                If y + 1 < q.Count Then
                    listDiff.Add(DateDiff(DateInterval.Day, q(y).Key, q(y + 1).Key))
                End If

so this is the code I was talking about... and its long... any idea how I could speed up by minutes ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Where are you using 'x'  in this code?
Seems you are not using x anywhere and you are running the same code last.Count times.
PhilippeRenaudAuthor Commented:
sorry right after :

For x As Integer = 0 To last.Count - 1
im using :

Dim arrString = last(x).Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries)
then i do the Dim q = .....
What is last made up of?
What does each item in last have contained within it?
What do the KeyValuePair(Of Date, String) in the dictionary represent?

CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

PhilippeRenaudAuthor Commented:
1) Last is a list (Of String) there are around 2415 rows.
in it its combinations of numbers 9but as string) like this :


2415 rows of those...

2) in the dictionary, the key is a date, and the value is a long string of number
lets say:  

11/11/2014 ,   "04, 08, 11, 12, 13, 14, 24, 56, 69"

so what I do is that i look for for the last(x) that is "01,02" does it contains in the dicitonnary and return me all the rows with the LINQ.
then I loop the results and I get the dateInterval between every rows.
Try this:

For x As Integer = 0 To last.Count - 1 
	Dim arrString = last(x).Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries)

	'q will select the dates from MyItems which contain last(x) in it
             Dim q = (From m In MyItems
                     Where arrString.All(Function(v) m.Value.Contains(v))
                     Select m.Key)

	     ' Get the day difference between adjacent dates
	     Dim diff = q.Zip(q.Skip(1), Function(d1, d2) DateDiff(DateInterval.Day, d1, d2));

	     For Each item In diff
  	     Next item

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
Why did you choose the data structures that you did for this code? What was your goal when you made those choices?
PhilippeRenaudAuthor Commented:
Thanks, thats really fast.... amazing.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.