Home All Groups Group Topic Archive Search About

variable declaration ?

Author
22 Jun 2006 8:09 PM
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.

Author
23 Jun 2006 2:07 AM
Linda Liu [MSFT]
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.
====================================================
Author
23 Jun 2006 5:17 AM
GhostInAK
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

Show quoteHide quote
> 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.
>
Author
23 Jun 2006 5:29 AM
Cor Ligthert [MVP]
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
Author
23 Jun 2006 6:07 AM
Cor Ligthert [MVP]
typing error,

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

Cor

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schreef in bericht
news:%23lcr2WolGHA.4164@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
>
>
Author
23 Jun 2006 3:36 PM
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.

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23lcr2WolGHA.4164@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
>
>
Author
26 Jun 2006 10:34 AM
Linda Liu [MSFT]
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.
====================================================