VB.Net Syntax...

J

Jimmy

I have C# code as follows.
//create instance of source web form
WebForm1 wf1;
//get reference to current handler instance
wf1=(WebForm1)Context.Handler;
Label1.Text=wf1.Name;
Label2.Text=wf1.EMail;

What is the equivavlent code in VB.Net ?
I am writing application in ASP.Net.
Thanks,
Jimmy
 
T

Teemu Keiski

Hi,

Just raw translation:

Dim wf1 As WebForm1=CType(Context.Handler,WebForm1)
Label1.Text=wf1.Name
Label2.Text=wf1.Email

BTW: Having "WebForm1 wf1;" does not create an instance of it, it declares a
member variable (or local variable) which is of type WebForm1 (but
uninitialized). Creating instance means when you create new instance with
'new' keyword (with classes) or assign primitive type to variable (with
value types where having literal can be understood as creating new instance
as well). Oh well, any way. :)
 
K

Kevin Spencer

BTW: Having "WebForm1 wf1;" does not create an instance of it, it declares
a
member variable (or local variable) which is of type WebForm1 (but
uninitialized). Creating instance means when you create new instance with
'new' keyword (with classes) or assign primitive type to variable (with
value types where having literal can be understood as creating new instance
as well). Oh well, any way. :)

Wait a second! He's assigning a value to it, which means that it is not
necessary or desirable to create a new instance.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

Teemu Keiski

Yeah, I was referring to the comment at top of the code, nothing more (just
explanation of difference in having uninitialized variable and assigning
instance to it).

There was:

//create instance of source web form //<--I targeted it at this line
//WebForm1 wf1;

Sorry for being unclear.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

Kevin Spencer said:
BTW: Having "WebForm1 wf1;" does not create an instance of it, it declares a
member variable (or local variable) which is of type WebForm1 (but
uninitialized). Creating instance means when you create new instance with
'new' keyword (with classes) or assign primitive type to variable (with
value types where having literal can be understood as creating new instance
as well). Oh well, any way. :)

Wait a second! He's assigning a value to it, which means that it is not
necessary or desirable to create a new instance.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
K

Kevin Spencer

Understood. :)

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top