Help on

Posted on 2006-05-26
Last Modified: 2010-04-23
Is there an easier way to program this code?  This is just a portion of a larger code but this is what I'm concerned with.

count = 1
     For Each objfileinfo1 In objDir.GetFiles()

            For Each lookuprow In ShippingPath1.ShipPath 'This is a dataset
                If lookuprow.Item(0) = (shipfield + count) Then
                    output = lookuprow.Item(1)

                End If

            count += 1
            Debug.WriteLine("This will be deleted", output)
            File.Move(objfileinfo1.FullName, output)
            Debug.WriteLine("File move", objfileinfo1.FullName)
            Debug.WriteLine(output, " of the move")

        MsgBox("Done Please double check your work!", MsgBoxStyle.Critical)

Just want to move next in the dataset without going thru a for do loop.
Question by:plenahan
    LVL 8

    Accepted Solution

    Ummm.  Are you concerned with speed?

    Dim myArray as new ArrayList

    myArray.AddRange (ShippingPath1.ShipPath)

    'sort it

    'look for first occurence
    'is it .Find?  Do not have VS installd here ^_^
    Dim startOffset as Long = myArray.Find (shipfield + count)  

    For ctr as long = startOffset to myArray.Length - 1
        if myArray(ctr) <> shipfield + count Then Exit For
        output = lookuprow.Item(1)
    Next ctr                                                          

    Author Comment

    I'll check this out and let you know. Sorry that's it's taken so long for me to reply. :)

    LVL 8

    Expert Comment

    No problem.

    If you can further explain what this code does, I might be able to give you a better code.


    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now