Problem understanding Overload methods

Posted on 2004-11-07
Last Modified: 2010-05-18
I'm creating a class module that simulates trucks arriving and departing from the terminal. I would like some help creating the code for some overloaded methods. The first method named AddTruck should except one argument, the TruckID. also set the arrival time to the current time. The second method should accept two arguments: the TruckID and the arrival time.also set the arrival time to the value specified in the second argument. The explanations in the book I'm learning from are not helping me.

Your help is always appreciated. Thanks
Question by:augie0216
    1 Comment
    LVL 27

    Accepted Solution

    Hi augie0216:
    Should not be difficult

        Public Sub AddTruck(TruckId as Integer)
            mTruckId = TruckID
            mArrivalTime = Now
        End Sub

        Public Sub AddTruck(TruckId as Integer, ArrivalTime as date)
            mTruckId = TruckId
            mArrivalTime = ArrivalTime
        End Sub

    You can also accomplish the same effect without overloading, using an optional parameter thus:

        Public Sub AddTruck(TruckId as Integer, Optional ArrivalDate = Now)
            mTruckId = TruckId
            mArrivalTime = ArrivalTime
        End Sub


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    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.

    733 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

    25 Experts available now in Live!

    Get 1:1 Help Now