Argument not specified

  • Thread starter Thread starter portroe
  • Start date Start date
P

portroe

anybody have an idea on what i am doing wrong here,

Argument not specified for parameter 'JobTitle' of 'Public Sub
New(JobTitle As String, NumberOfEmployees As Integer)'.

thanks

Portroe
 
portroe said:
anybody have an idea on what i am doing wrong here,

Argument not specified for parameter 'JobTitle' of 'Public Sub
New(JobTitle As String, NumberOfEmployees As Integer)'.

How can we know as you don't tell us how you call the sub?
 
* portroe said:
anybody have an idea on what i am doing wrong here,

Argument not specified for parameter 'JobTitle' of 'Public Sub
New(JobTitle As String, NumberOfEmployees As Integer)'.

Post the code you use to create the new object (the constructor call).
 
'this is the constructor from the course class,

Public Sub New(ByVal JobTitle As String, ByVal NumberOfEmployees As Integer)
Me.iJobTitle = JobTitle
Me.iNumberOfEmployees = NumberOfEmployees
Me.iFreeOfCharge = ""
End Sub

'thanks
 
* portroe said:
'this is the constructor from the course class,

Public Sub New(ByVal JobTitle As String, ByVal NumberOfEmployees As Integer)
Me.iJobTitle = JobTitle
Me.iNumberOfEmployees = NumberOfEmployees
Me.iFreeOfCharge = ""
End Sub

'thanks

And how do you call it? Where does the error occur?
 
portroe said:
'this is the constructor from the course class,

Public Sub New(ByVal JobTitle As String, ByVal NumberOfEmployees As
Integer)
Me.iJobTitle = JobTitle
Me.iNumberOfEmployees = NumberOfEmployees
Me.iFreeOfCharge = ""
End Sub


The question was how the sub is called, i.e. what is the code to create the
object?
 
Hi portroe,

Probably you create the object as this
dim myCourse as New course()
while it has to be
dim myCourse as New course("Programmers",1000)

Just a gues?

Cor

 
* portroe said:
The error occurs when i try to debug, Ireceive this as a build error,

Post the line where the error occurs (must be something like '... New
SomeType(...)'. Maybe you are missing to specify a parameter value or
you are passing wring data.
 
portroe said:
the error occurs in the following line

Dim MyCourse As New Course()

Quite right too.
Your Course class "Constructor" (Sub New) is declared as taking
two arguments, JobTitle and NumberOfEmployees. That means
that *every* time you want to create an object of type Course,
you *must* supply both arguments. In this code, you haven't, so
it won't compile.

If you really /want/ to be able to create Course objects /without/
specifying these arguments (and I /don't/ think you do), then add
another Sub New to the Course Class that takes no arguments.

HTH,
Phill W.
 
Thanks guys that was it,

The new object demands the numberofemployees
this I had defined by the constructor, but no value is assigned to the
Object “MyCourse”.

OO Programming has a steep learning curve at the beginning,

greets

portroe
 
Back
Top