473,387 Members | 1,456 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,387 software developers and data experts.

Where is Sub New

I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.

Can you tell me where it is?
thanks
Feb 28 '07 #1
10 1089
There is a default constructor provided by .Net. If you don't see one, then
that's what's being used. You can just add your own to your class, and it
will use yours instead of the default. Also, if you add any constructors,
..Net assumes you will create all constructors that you want, and will not
create a default one behind the scenes.

Robin S.
----------------------------
" active" <ac**********@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
>I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.

Can you tell me where it is?
thanks

Feb 28 '07 #2
Maybe this solves a problem I had a while ago.

If the constructor can have arguments.

I needed the constructor to have arguments so that the calling form could
set some properties before Initialize was run.

I can't quite see how the Ide can handle a constructor with arguments but
I'll play with it.

Thanks again

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:xc******************************@comcast.com. ..
There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you want,
and will not create a default one behind the scenes.

Robin S.
----------------------------
" active" <ac**********@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
>>I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.

Can you tell me where it is?
thanks


Mar 1 '07 #3
I can't quite see how the Ide can handle a constructor with arguments

The only time it causes any troubles is if it is a control/component
that is added to a form/usercontrol in designer mode. In that case the
designer won't know what to do since it can't specify the parameters.
You should be able to manually edit the designer generated code is the
easiest way to cope with this. (but be warned it can/will overwrite
your changes when it wants to).

Thanks,

Seth Rowe
On Mar 1, 10:16 am, " active" <activeNOS...@a-znet.comwrote:
Maybe this solves a problem I had a while ago.

If the constructor can have arguments.

I needed the constructor to have arguments so that the calling form could
set some properties before Initialize was run.

I can't quite see how the Ide can handle a constructor with arguments but
I'll play with it.

Thanks again

"RobinS" <Rob...@NoSpam.yah.nonewrote in message

news:xc******************************@comcast.com. ..
There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you want,
and will not create a default one behind the scenes.
Robin S.
----------------------------
" active" <activeNOS...@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
>I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.
Can you tell me where it is?
thanks

Mar 1 '07 #4
I tried this with a vs2003 style project and it seems to work OK.

Public Sub New(ByVal test As String)

MyBase.New()

InitializeComponent()

Text = test

That is, when I run it the form's text displays what the caller set the
parameter to.

I cunfused about what the Ide does.

I changed the last line to

Text = "MORE JUNK"

But again the IDE did not display it.

It does create an instance of the class doesn't it?

Could it be that Net develops a constructor with no arguments if I don't?

Thanks

I'm thinking about redoing that app since it would be so much neater an less
error prone this way but it would not be a trivial change so I want to be
sure before I start.

I trying to think of other tests but have not come up with anything yet.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:xc******************************@comcast.com. ..
There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you want,
and will not create a default one behind the scenes.

Robin S.
----------------------------
" active" <ac**********@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
>>I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.

Can you tell me where it is?
thanks


Mar 1 '07 #5
I ran a simple test with a form and the Ide seemed to ignore my constructor
when it displayed the form. I can't figure what it is doing.

Why is it OK with a Form but not with a control/component ?

I was hoping the designer would do something like supply all empty arguments
or something like that.

Thanks for the help

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
>I can't quite see how the Ide can handle a constructor with arguments

The only time it causes any troubles is if it is a control/component
that is added to a form/usercontrol in designer mode. In that case the
designer won't know what to do since it can't specify the parameters.
You should be able to manually edit the designer generated code is the
easiest way to cope with this. (but be warned it can/will overwrite
your changes when it wants to).

Thanks,

Seth Rowe
On Mar 1, 10:16 am, " active" <activeNOS...@a-znet.comwrote:
>Maybe this solves a problem I had a while ago.

If the constructor can have arguments.

I needed the constructor to have arguments so that the calling form could
set some properties before Initialize was run.

I can't quite see how the Ide can handle a constructor with arguments but
I'll play with it.

Thanks again

"RobinS" <Rob...@NoSpam.yah.nonewrote in message

news:xc******************************@comcast.com ...
There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you
want,
and will not create a default one behind the scenes.
Robin S.
----------------------------
" active" <activeNOS...@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.
>Can you tell me where it is?
>thanks


Mar 1 '07 #6
I don't think .Net provides a default constructor if you provide a
non-default one. So how is it instantiating? I don't know, maybe I'm wrong.
If I didn't want anybody to be able to create this form without providing
the input string, I would add a default constructor and make it private.

If you want your main form to have a string passed in to it, you can't have
the startup object be a form. You have to make a sub main and instantiate
and show your form from there.

Robin S.
-------------------------------
" active" <ac**********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>I tried this with a vs2003 style project and it seems to work OK.

Public Sub New(ByVal test As String)

MyBase.New()

InitializeComponent()

Text = test

That is, when I run it the form's text displays what the caller set the
parameter to.

I cunfused about what the Ide does.

I changed the last line to

Text = "MORE JUNK"

But again the IDE did not display it.

It does create an instance of the class doesn't it?

Could it be that Net develops a constructor with no arguments if I don't?

Thanks

I'm thinking about redoing that app since it would be so much neater an
less error prone this way but it would not be a trivial change so I want
to be sure before I start.

I trying to think of other tests but have not come up with anything yet.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:xc******************************@comcast.com. ..
>There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you
want, and will not create a default one behind the scenes.

Robin S.
----------------------------
" active" <ac**********@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
>>>I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.

Can you tell me where it is?
thanks



Mar 1 '07 #7
On Mar 1, 11:31 am, " active" <activeNOS...@a-znet.comwrote:
I tried this with a vs2003 style project and it seems to work OK.

Public Sub New(ByVal test As String)

MyBase.New()

InitializeComponent()

Text = test

That is, when I run it the form's text displays what the caller set the
parameter to.

I cunfused about what the Ide does.

I changed the last line to

Text = "MORE JUNK"

But again the IDE did not display it.

It does create an instance of the class doesn't it?

Could it be that Net develops a constructor with no arguments if I don't?

Thanks

I'm thinking about redoing that app since it would be so much neater an less
error prone this way but it would not be a trivial change so I want to be
sure before I start.

I trying to think of other tests but have not come up with anything yet.

"RobinS" <Rob...@NoSpam.yah.nonewrote in message

news:xc******************************@comcast.com. ..
There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you want,
and will not create a default one behind the scenes.
Robin S.
----------------------------
" active" <activeNOS...@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
>I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.
Can you tell me where it is?
thanks
Make sure there is no constructor defined in the designer.vb file for
your form. Sometimes the ide will add the constructor there. Also,
just press F8 to start stepping through the code and see if a
different constructor is being called than your parameterized one.

Thanks,

Seth Rowe

Mar 1 '07 #8
That pesky designer code... ;-)

Robin S.
----------------------------
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@n33g2000cwc.googlegro ups.com...
On Mar 1, 11:31 am, " active" <activeNOS...@a-znet.comwrote:
>I tried this with a vs2003 style project and it seems to work OK.

Public Sub New(ByVal test As String)

MyBase.New()

InitializeComponent()

Text = test

That is, when I run it the form's text displays what the caller set the
parameter to.

I cunfused about what the Ide does.

I changed the last line to

Text = "MORE JUNK"

But again the IDE did not display it.

It does create an instance of the class doesn't it?

Could it be that Net develops a constructor with no arguments if I
don't?

Thanks

I'm thinking about redoing that app since it would be so much neater an
less
error prone this way but it would not be a trivial change so I want to
be
sure before I start.

I trying to think of other tests but have not come up with anything yet.

"RobinS" <Rob...@NoSpam.yah.nonewrote in message

news:xc******************************@comcast.com ...
There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your
class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you
want,
and will not create a default one behind the scenes.
Robin S.
----------------------------
" active" <activeNOS...@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.
>Can you tell me where it is?
>thanks

Make sure there is no constructor defined in the designer.vb file for
your form. Sometimes the ide will add the constructor there. Also,
just press F8 to start stepping through the code and see if a
different constructor is being called than your parameterized one.

Thanks,

Seth Rowe

Mar 1 '07 #9

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@n33g2000cwc.googlegro ups.com...
On Mar 1, 11:31 am, " active" <activeNOS...@a-znet.comwrote:
>I tried this with a vs2003 style project and it seems to work OK.

Public Sub New(ByVal test As String)

MyBase.New()

InitializeComponent()

Text = test

That is, when I run it the form's text displays what the caller set the
parameter to.

I cunfused about what the Ide does.

I changed the last line to

Text = "MORE JUNK"

But again the IDE did not display it.

It does create an instance of the class doesn't it?

Could it be that Net develops a constructor with no arguments if I don't?

Thanks

I'm thinking about redoing that app since it would be so much neater an
less
error prone this way but it would not be a trivial change so I want to be
sure before I start.

I trying to think of other tests but have not come up with anything yet.

"RobinS" <Rob...@NoSpam.yah.nonewrote in message

news:xc******************************@comcast.com ...
There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you
want,
and will not create a default one behind the scenes.
Robin S.
----------------------------
" active" <activeNOS...@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.
>Can you tell me where it is?
>thanks

Make sure there is no constructor defined in the designer.vb file for
This is the vs2003 style project
your form. Sometimes the ide will add the constructor there. Also,
just press F8 to start stepping through the code and see if a
different constructor is being called than your parameterized one.
Thanks
Mar 1 '07 #10
Thanks a lot

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:pO******************************@comcast.com. ..
>I don't think .Net provides a default constructor if you provide a
non-default one. So how is it instantiating? I don't know, maybe I'm wrong.
If I didn't want anybody to be able to create this form without providing
the input string, I would add a default constructor and make it private.

If you want your main form to have a string passed in to it, you can't
have the startup object be a form. You have to make a sub main and
instantiate and show your form from there.

Robin S.
-------------------------------
" active" <ac**********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>I tried this with a vs2003 style project and it seems to work OK.

Public Sub New(ByVal test As String)

MyBase.New()

InitializeComponent()

Text = test

That is, when I run it the form's text displays what the caller set the
parameter to.

I cunfused about what the Ide does.

I changed the last line to

Text = "MORE JUNK"

But again the IDE did not display it.

It does create an instance of the class doesn't it?

Could it be that Net develops a constructor with no arguments if I don't?

Thanks

I'm thinking about redoing that app since it would be so much neater an
less error prone this way but it would not be a trivial change so I want
to be sure before I start.

I trying to think of other tests but have not come up with anything yet.

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:xc******************************@comcast.com ...
>>There is a default constructor provided by .Net. If you don't see one,
then that's what's being used. You can just add your own to your class,
and it will use yours instead of the default. Also, if you add any
constructors, .Net assumes you will create all constructors that you
want, and will not create a default one behind the scenes.

Robin S.
----------------------------
" active" <ac**********@a-znet.comwrote in message
news:uI*************@TK2MSFTNGP05.phx.gbl...
I have a couple of projects in the VS2005 format using Partial Class.
I can't find where the code for sub New is stored.

Can you tell me where it is?
thanks



Mar 1 '07 #11

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

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
3
by: A.V.C. | last post by:
Hello, I found members of this group very helpful for my last queries. Have one problem with CASE. I can use the column name alias in Order By Clause but unable to use it in WHERE CLAUSE. PLS...
3
by: Xiangliang Meng | last post by:
Hi, all. In 1998, I graduated from Computer Science Dept. in a university in China. Since then, I've been using C Language for almost 6 years. Although I'm using C++ in my current job, I'm also...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
5
by: comp.lang.php | last post by:
if ($willLimitByDB) $sql = preg_replace('/#(+)#/i', '$$1', $sql); This does not give me the results I want, instead of the value of $where in $sql, I literally get '$where' instead. How do I...
5
by: John | last post by:
I just cannot manage to perform a SELECT query with NULL parameter... My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB null value). TCATEGORYID and TCATEGORYPARENTID...
0
NeoPa
by: NeoPa | last post by:
Background Whenever code is used there must be a way to differentiate the actual code (which should be interpreted directly) with literal strings which should be interpreted as data. Numbers don't...
1
by: not_a_commie | last post by:
I was hoping for increased functionality with the where clause in C# 3.0. Using the new keyword 'var' would really allow us to take nice advantage of these. Specifically: 1. I want to limit it...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
8
by: chrisdavis | last post by:
I'm trying to filter by query or put those values in a distinct query in a where clause in some sort of list that it goes through but NOT at the same time. Example: ROW1 ROW2 ROW3 ROW4 ,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.