?
Solved

Problem understanding Overload methods

Posted on 2004-11-07
1
Medium Priority
?
222 Views
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 vb.net from are not helping me.

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

Accepted Solution

by:
Dabas earned 1000 total points
ID: 12516659
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

Dabas
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Loops Section Overview
Screencast - Getting to Know the Pipeline

839 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