473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Create an object


I am new to VB.NET. Anyone could give a hint? Thanks.
What is the problem about the following code:

Dim myPrincipal As CustomPrincipal = New CustomPrincipal(id, roles)

where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles As
String())

the error message:
Too many arguments to 'Public Sub New()'.
Nov 19 '05 #1
6 1019
A Sub is not a class. The New Operator is for creating instances of classes.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"david" <da***@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...

I am new to VB.NET. Anyone could give a hint? Thanks.
What is the problem about the following code:

Dim myPrincipal As CustomPrincipal = New CustomPrincipal(id, roles)

where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles As
String())

the error message:
Too many arguments to 'Public Sub New()'.

Nov 19 '05 #2
Hello David,

I think you need to define the constructor as

Public Sub New(ByVal identity As IIdentity, ByVal roles As String())

--
Matt Berther
http://www.mattberther.com
I am new to VB.NET. Anyone could give a hint? Thanks. What is the
problem about the following code:

Dim myPrincipal As CustomPrincipal = New CustomPrincipal(id, roles)

where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles
As
String())
the error message:
Too many arguments to 'Public Sub New()'.

Nov 19 '05 #3
Hi
I am a new ASP.NET programmer

In VB.NET the constructor name should be New and not the class name (C#
constructor name is the class name)

If there is no constructor declared with New keyword then the runtime will
create a default parameterless constructor for you.

So the solution may be:

One: change your constructor name to New instead of CustomPrincipal

Dim myPrincipal As CustomPrincipal = New CustomPrincipal(id, roles)

where CustomPrincipal is constructor defined as
Public Sub New(ByVal identity As IIdentity, ByVal roles As String())

or

Two create the object without any arguments passed to it
Dim myPrincipal As CustomPrincipal = New CustomPrincipal()
where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles As
String())


"david" <da***@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
I am new to VB.NET. Anyone could give a hint? Thanks.
What is the problem about the following code:

Dim myPrincipal As CustomPrincipal = New CustomPrincipal(id, roles)

where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles As
String())

the error message:
Too many arguments to 'Public Sub New()'.

Nov 19 '05 #4
Using the name of the class for the constructor is a (C#) language
convention. In VB.NET contrcutors are using always the name "New"...

Patrice

--

"david" <da***@discussions.microsoft.com> a écrit dans le message de
news:06**********************************@microsof t.com...

I am new to VB.NET. Anyone could give a hint? Thanks.
What is the problem about the following code:

Dim myPrincipal As CustomPrincipal = New CustomPrincipal(id, roles)

where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles As
String())

the error message:
Too many arguments to 'Public Sub New()'.

Nov 19 '05 #5
Cyn
Try

Dim myPrincipal as New CustomPrincipal(id, roles)

I assume your parameters are of the correct type

Hope that helps
-----Original Message-----

I am new to VB.NET. Anyone could give a hint? Thanks.
What is the problem about the following code:

Dim myPrincipal As CustomPrincipal = New CustomPrincipal (id, roles)
where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles AsString())

the error message:
Too many arguments to 'Public Sub New()'.
.

Nov 19 '05 #6
As kevin says, you need to create a constructor...

Publc Sub New(ByVal identity As IIdentity, ByVal roles As String())

perhaps you are used to C# where the constructor is the name of the
class...in VB.Net, you use the New keyword as the constructor name...

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
A Sub is not a class. The New Operator is for creating instances of classes.
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"david" <da***@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...

I am new to VB.NET. Anyone could give a hint? Thanks.
What is the problem about the following code:

Dim myPrincipal As CustomPrincipal = New CustomPrincipal(id, roles)

where CustomPrincipal is constructor defined as
Public Sub CustomPrincipal(ByVal identity As IIdentity, ByVal roles As
String())

the error message:
Too many arguments to 'Public Sub New()'.


Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Just D. | last post by:
All, Do we have a simple way to Create an object on the fly knowing just an object type? The usual design-time way is to write a code something like this: CObjectType obj = new CObjectType();...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
2
by: Big Charles | last post by:
Hello, I would like to create an array-class to be able to call like: Dim oMyCar as New MyCar ' After initializing oMyCar, the object has to be like: oMyCar(0).Brand...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
1
by: Dave | last post by:
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.