Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Option Strict Error


Message #1 by "Alvin Ling" <alvin.ling@i...> on Mon, 28 Jan 2002 14:27:41 -0500
I'm setting a session variable via Session_OnStart() in my global.asax



Sub Session_OnStart()



	Session("foo") = "bar"



End Sub



But when I test for it on a page:



If Session("foo") = "bar" Then...



I get the following error:



"BC32013: Option Strict On disallows operands of type Object for

operator '='. Use the 'Is' operator to test for object identity."





I've verified that the Session("foo") does evaluate to a "String" via

TypeName()... help?





Alvin











Message #2 by "Gerry Crowe" <gerry@g...> on Mon, 28 Jan 2002 20:35:53 -0000
> I'm setting a session variable via Session_OnStart() in my global.asax

>

> Sub Session_OnStart()

>

> Session("foo") = "bar"

>

> End Sub



Doesn't "foo" have to be in brackets ["foo"] rather than parentheses

("foo")?



Gerry



Message #3 by "McCloy, Russell" <Russell.McCloy@B...> on Tue, 29 Jan 2002 08:02:30 +1100
Isnt that just for arrays?



-----Original Message-----

From: Gerry Crowe [mailto:gerry@g...]

Sent: Tuesday, 29 January 2002 7:36 AM

To: aspx_beginners

Subject: [aspx_beginners] Re: Option Strict Error





> I'm setting a session variable via Session_OnStart() in my global.asax

>

> Sub Session_OnStart()

>

> Session("foo") = "bar"

>

> End Sub



Doesn't "foo" have to be in brackets ["foo"] rather than parentheses

("foo")?



Gerry








$subst('Email.Unsub').

Message #4 by "Graham Dobson" <grahamdo@a...> on Mon, 28 Jan 2002 16:09:25 -0500
In C# an index string for any kind of collection is ["indexstring"] but in

VB isn't it still ("indexstring")?



----- Original Message -----

From: "McCloy, Russell" <Russell.McCloy@B...>

To: "aspx_beginners" <aspx_beginners@p...>

Sent: Monday, January 28, 2002 4:02 PM

Subject: [aspx_beginners] Re: Option Strict Error





> Isnt that just for arrays?

>

> -----Original Message-----

> From: Gerry Crowe [mailto:gerry@g...]

> Sent: Tuesday, 29 January 2002 7:36 AM

> To: aspx_beginners

> Subject: [aspx_beginners] Re: Option Strict Error

>

>

> > I'm setting a session variable via Session_OnStart() in my global.asax

> >

> > Sub Session_OnStart()

> >

> > Session("foo") = "bar"

> >

> > End Sub

>

> Doesn't "foo" have to be in brackets ["foo"] rather than parentheses

> ("foo")?

>

> Gerry

>

>




> $subst('Email.Unsub').

>




$subst('Email.Unsub').

>



Message #5 by "Alvin Ling" <alvin.ling@i...> on Mon, 28 Jan 2002 16:08:15 -0500
I've found the problem - possibly a .NET vs VB issue?



Even though TypeName(Session("foo")) evaluates to a String type,

apparently .NET doesn't think so.  I ended up using the .NET conversion

to solve the comparison issue.



	If Session("foo").ToString() = "bar" Then



works fine.



Can someone explain this discrepancy?





Alvin





> -----Original Message-----

> From: McCloy, Russell [mailto:Russell.McCloy@B...] 

> Sent: Monday, January 28, 2002 4:03 PM

> To: aspx_beginners

> Subject: [aspx_beginners] Re: Option Strict Error

> 

> 

> Isnt that just for arrays?

> 

> -----Original Message-----

> From: Gerry Crowe [mailto:gerry@g...]

> Sent: Tuesday, 29 January 2002 7:36 AM

> To: aspx_beginners

> Subject: [aspx_beginners] Re: Option Strict Error

> 

> 

> > I'm setting a session variable via Session_OnStart() in my 

> global.asax

> >

> > Sub Session_OnStart()

> >

> > Session("foo") = "bar"

> >

> > End Sub

> 

> Doesn't "foo" have to be in brackets ["foo"] rather than 

> parentheses ("foo")?

> 

> Gerry

> 

> 




> $subst('Email.Unsub').

> 




> $subst('Email.Unsub').

> 

> 









Message #6 by "Denis" <dgobo@w...> on Mon, 28 Jan 2002 16:11:21 -0500
I think because it stores the session as an Object  same thing is true

in Java





-----Original Message-----

From: Alvin Ling [mailto:alvin.ling@i...] 

Sent: Monday, January 28, 2002 4:08 PM

To: aspx_beginners

Subject: [aspx_beginners] Re: Option Strict Error





I've found the problem - possibly a .NET vs VB issue?



Even though TypeName(Session("foo")) evaluates to a String type,

apparently .NET doesn't think so.  I ended up using the .NET conversion

to solve the comparison issue.



	If Session("foo").ToString() = "bar" Then



works fine.



Can someone explain this discrepancy?





Alvin





> -----Original Message-----

> From: McCloy, Russell [mailto:Russell.McCloy@B...]

> Sent: Monday, January 28, 2002 4:03 PM

> To: aspx_beginners

> Subject: [aspx_beginners] Re: Option Strict Error

> 

> 

> Isnt that just for arrays?

> 

> -----Original Message-----

> From: Gerry Crowe [mailto:gerry@g...]

> Sent: Tuesday, 29 January 2002 7:36 AM

> To: aspx_beginners

> Subject: [aspx_beginners] Re: Option Strict Error

> 

> 

> > I'm setting a session variable via Session_OnStart() in my

> global.asax

> >

> > Sub Session_OnStart()

> >

> > Session("foo") = "bar"

> >

> > End Sub

> 

> Doesn't "foo" have to be in brackets ["foo"] rather than

> parentheses ("foo")?

> 

> Gerry

> 

> 




> $subst('Email.Unsub').

> 




> $subst('Email.Unsub').

> 

> 














$subst('Email.Unsub').



Message #7 by "Alexander Kapinos" <alkapin@h...> on Mon, 28 Jan 2002 13:30:18 -0800
It's easy:



Session("foo") return type is object



Session("foo").ToString() return type is string





-----Original Message-----

From: Alvin Ling [mailto:alvin.ling@i...] 

Sent: Monday, January 28, 2002 1:08 PM

To: aspx_beginners

Subject: [aspx_beginners] Re: Option Strict Error





I've found the problem - possibly a .NET vs VB issue?



Even though TypeName(Session("foo")) evaluates to a String type,

apparently .NET doesn't think so.  I ended up using the .NET conversion

to solve the comparison issue.



	If Session("foo").ToString() = "bar" Then



works fine.



Can someone explain this discrepancy?





Alvin





> -----Original Message-----

> From: McCloy, Russell [mailto:Russell.McCloy@B...]

> Sent: Monday, January 28, 2002 4:03 PM

> To: aspx_beginners

> Subject: [aspx_beginners] Re: Option Strict Error

>

>

> Isnt that just for arrays?

>

> -----Original Message-----

> From: Gerry Crowe [mailto:gerry@g...]

> Sent: Tuesday, 29 January 2002 7:36 AM

> To: aspx_beginners

> Subject: [aspx_beginners] Re: Option Strict Error

>

>

> > I'm setting a session variable via Session_OnStart() in my

> global.asax

> >

> > Sub Session_OnStart()

> >

> > Session("foo") = "bar"

> >

> > End Sub

>

> Doesn't "foo" have to be in brackets ["foo"] rather than parentheses 

> ("foo")?

>

> Gerry

>

>

> ---

> Change your mail options at http://p2p.wrox.com/manager.asp or to 

> unsubscribe send a blank email to 

> $subst('Email.Unsub').

>

> ---

> Change your mail options at http://p2p.wrox.com/manager.asp or to 

> unsubscribe send a blank email to 

> $subst('Email.Unsub').

>

>











---

Change your mail options at http://p2p.wrox.com/manager.asp or to

unsubscribe send a blank email to

$subst('Email.Unsub').


  Return to Index