By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 2,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

variable declaration ?

P: n/a
rJ
hi,

what does the following statement mean and what does it do?

Dim obTest As Record.Class1 =
CType(Class2.GetSessionInfo(class3.TestConstant), Record.Class1)

GetSessionInfo() simply does this Return Me.Session(name)

TestConstant is a contstant containing "test.tester"

What does me.session(name) do?

Also, since class1 has many methods, about 10 properties, and 2 collections
does this assign structure of properties to obTest?

Thanks a lot.

Jun 22 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi,

Thank you for posting.

It's hard for me to explain the statement at this point. Would you please
show me the whole related code including the definition of Class1, Class2
and Class3?

I look forward to your reply.

Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 23 '06 #2

P: n/a
Hello RJ,

Simple... Let's break it down.

Dim obTest As Record.Class1 ' This creates a variable named obTest with
a data type of Record.Class1
the = sign in a Dim statement means that the right side of the expression
will be used to initialize the variable

CType converts parameter1 into a variable of datatype parameter2... So:
Class2.GetSessionInfo(class3.TestConstant) gets converted into a Record.Class1..
which then gets assigned to obTest.

Simple eh.

-Boo
hi,

what does the following statement mean and what does it do?

Dim obTest As Record.Class1 =
CType(Class2.GetSessionInfo(class3.TestConstant), Record.Class1)

GetSessionInfo() simply does this Return Me.Session(name)

TestConstant is a contstant containing "test.tester"

What does me.session(name) do?

Also, since class1 has many methods, about 10 properties, and 2
collections does this assign structure of properties to obTest?

Thanks a lot.

Jun 23 '06 #3

P: n/a
RJ,

See inline

Dim obTest As Record.Class1 =
CType(Class2.GetSessionInfo(class3.TestConstant), Record.Class1)
This means that you create an Object obTest, that holds the reference to the
object Class2.GetSessionInfo(class3.TestConstant).

You can use that obTest object now direct without everytime to use that long
description.
(The word DirectCast instead of CType (convert type) would here probably be
better)

GetSessionInfo() simply does this Return Me.Session(name)
I don't see this on MSDN, which means that it is a method in your program
(class)
TestConstant is a contstant containing "test.tester"

What does me.session(name) do?

A session is a temporaly storage used to holds data between send and
postback from webpages.
Also, since class1 has many methods, about 10 properties, and 2
collections does this assign structure of properties to obTest?

The difference between a Class and a structure is the place where it is in
memory. A structure is always direct in your mainprogram on the main heap an
therefore inefficient. A class is on the managed heap, and can be destroyed
(is automaticly done by the managed code) when not needed anymore/

Therefore if something is in a class, than it is in the class and not in a
structure. (Although a class can reference to a structure).

I hope this helps,

Cor
Jun 23 '06 #4

P: n/a
typing error,

Main heap has to be Main stack, my thought was already something further in
the message.

Cor

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
RJ,

See inline

Dim obTest As Record.Class1 =
CType(Class2.GetSessionInfo(class3.TestConstant), Record.Class1)


This means that you create an Object obTest, that holds the reference to
the object Class2.GetSessionInfo(class3.TestConstant).

You can use that obTest object now direct without everytime to use that
long description.
(The word DirectCast instead of CType (convert type) would here probably
be better)

GetSessionInfo() simply does this Return Me.Session(name)

I don't see this on MSDN, which means that it is a method in your program
(class)
TestConstant is a contstant containing "test.tester"

What does me.session(name) do?


A session is a temporaly storage used to holds data between send and
postback from webpages.
Also, since class1 has many methods, about 10 properties, and 2
collections does this assign structure of properties to obTest?

The difference between a Class and a structure is the place where it is in
memory. A structure is always direct in your mainprogram on the main heap
an therefore inefficient. A class is on the managed heap, and can be
destroyed (is automaticly done by the managed code) when not needed
anymore/

Therefore if something is in a class, than it is in the class and not in a
structure. (Although a class can reference to a structure).

I hope this helps,

Cor

Jun 23 '06 #5

P: n/a
rJ
First of all...thank you all for your responses. It is greatly appreciated.
GetSessionInfo() simply does this Return Me.Session(name)

I don't see this on MSDN, which means that it is a method in your program
(class)

It is a method in my code that contains only
Return Me.Session(name)

The value of class3.TestConstant is "test.tester" at run time according to
debug. I see where the constant is assigned in class3. So at run time
Class2.GetSessionInfo(class3.TestConstant) is equal to "test.tester" so
statement would then be
CType("test.tester", Record.Class1).

How is "test.test" being returned as Record.Class1?

I just don't get what CType(Class2.GetSessionInfo(class3.TestConstant),
Record.Class1) is doing and why you would want to do this? :(

Why not just stop at
Dim obTest As Record.Class1

Why is the initial value being set to
CType(Class2.GetSessionInfo(class3.TestConstant), Record.Class1)

Finally, why don't we have to have New keyword behind as in variable
declaration? I have searched entire project and don't find a Dim obTest as
New Record.Class1.

Thanks again for your patience and assistance.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl... RJ,

See inline

Dim obTest As Record.Class1 =
CType(Class2.GetSessionInfo(class3.TestConstant), Record.Class1)


This means that you create an Object obTest, that holds the reference to
the object Class2.GetSessionInfo(class3.TestConstant).

You can use that obTest object now direct without everytime to use that
long description.
(The word DirectCast instead of CType (convert type) would here probably
be better)

GetSessionInfo() simply does this Return Me.Session(name)

I don't see this on MSDN, which means that it is a method in your program
(class)
TestConstant is a contstant containing "test.tester"

What does me.session(name) do?


A session is a temporaly storage used to holds data between send and
postback from webpages.
Also, since class1 has many methods, about 10 properties, and 2
collections does this assign structure of properties to obTest?

The difference between a Class and a structure is the place where it is in
memory. A structure is always direct in your mainprogram on the main heap
an therefore inefficient. A class is on the managed heap, and can be
destroyed (is automaticly done by the managed code) when not needed
anymore/

Therefore if something is in a class, than it is in the class and not in a
structure. (Although a class can reference to a structure).

I hope this helps,

Cor

Jun 23 '06 #6

P: n/a
Hi Rj,

Thank you for your update.

It seems that the expression "Class2.GetSessionInfo(class3.TestContant)"
returns a object of type Record.Class1. You can assign this returned object
to the variable obTest and needn't use New keyword.

Although the value of class3.TestConstant is "test.tester" at run time,
Class2.GetSessionInfo(class3.TestConstant) should not be equal to
"test.tester". It should be equal to the value of the expression of
"Me.Session(name)".

I think the core of the problem is the expression "Me.Session(name)", which
is not clear to us until now. In order to explain this expression, would
you please show us the entire related code?

I look forward to your reply.

Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 26 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.