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

Session("passed") = Session("passed") + 1 error

dee
Hi
My code complies the following line:
Session("passed") = 1
but puts wiggly error line under the second Session("passed") in the
following expression:
Session("passed") = Session("passed") + 1
Why?
Thanks
Dee.
Session("passed") = Session("passed") + 1

Session("passed") = Session("passed") + 1
Nov 19 '05 #1
13 1875
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"dee" <dee@home> wrote in message
news:uO*************@TK2MSFTNGP12.phx.gbl...
Hi
My code complies the following line:
Session("passed") = 1
but puts wiggly error line under the second Session("passed") in the
following expression:
Session("passed") = Session("passed") + 1
Why?
Thanks
Dee.
Session("passed") = Session("passed") + 1

Session("passed") = Session("passed") + 1

Nov 19 '05 #2
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"dee" <dee@home> wrote in message
news:uO*************@TK2MSFTNGP12.phx.gbl...
Hi
My code complies the following line:
Session("passed") = 1
but puts wiggly error line under the second Session("passed") in the
following expression:
Session("passed") = Session("passed") + 1
Why?
Thanks
Dee.
Session("passed") = Session("passed") + 1

Session("passed") = Session("passed") + 1

Nov 19 '05 #3
dee
Thanks Juan :)
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"dee" <dee@home> wrote in message
news:uO*************@TK2MSFTNGP12.phx.gbl...
Hi
My code complies the following line:
Session("passed") = 1
but puts wiggly error line under the second Session("passed") in the
following expression:
Session("passed") = Session("passed") + 1
Why?
Thanks
Dee.
Session("passed") = Session("passed") + 1

Session("passed") = Session("passed") + 1


Nov 19 '05 #4
dee
Thanks Juan :)
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"dee" <dee@home> wrote in message
news:uO*************@TK2MSFTNGP12.phx.gbl...
Hi
My code complies the following line:
Session("passed") = 1
but puts wiggly error line under the second Session("passed") in the
following expression:
Session("passed") = Session("passed") + 1
Why?
Thanks
Dee.
Session("passed") = Session("passed") + 1

Session("passed") = Session("passed") + 1


Nov 19 '05 #5
Juan T. Llibre wrote:
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.


Session("whatever") is not a string, it's an "object".
You can't cast a string to an int (you have to "parse" it),
but you can cast an object to an int (if it really *is* an int).
So your solution *does* work...

--
Hans Kesting
Nov 19 '05 #6
Juan T. Llibre wrote:
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.


Session("whatever") is not a string, it's an "object".
You can't cast a string to an int (you have to "parse" it),
but you can cast an object to an int (if it really *is* an int).
So your solution *does* work...

--
Hans Kesting
Nov 19 '05 #7
Hello, Hans.

While the Session object is an object ( of course ),
its *content* can be a string, as in this particular case
....where the 1 in Session("passed") = 1 is a string, not an object.

This works, for example :

Session("passed") = 1
Dim yNumber as String = Session("passed")
Dim jNumber as Integer = Int32.Parse(yNumber)
Dim wNumber as Integer = jNumber + jNumber
lblMessage.Text = wNumber.ToString()

You're right about the use of "casting", though.
That was a bit sloppy on my part.

I should have used "Convert.ToInt32" or "Parse".

Int32.Parse() is what Convert.ToInt32() calls, anyway, isn't it ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Juan T. Llibre wrote:
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.


Session("whatever") is not a string, it's an "object".
You can't cast a string to an int (you have to "parse" it),
but you can cast an object to an int (if it really *is* an int).
So your solution *does* work...

--
Hans Kesting

Nov 19 '05 #8
Hello, Hans.

While the Session object is an object ( of course ),
its *content* can be a string, as in this particular case
....where the 1 in Session("passed") = 1 is a string, not an object.

This works, for example :

Session("passed") = 1
Dim yNumber as String = Session("passed")
Dim jNumber as Integer = Int32.Parse(yNumber)
Dim wNumber as Integer = jNumber + jNumber
lblMessage.Text = wNumber.ToString()

You're right about the use of "casting", though.
That was a bit sloppy on my part.

I should have used "Convert.ToInt32" or "Parse".

Int32.Parse() is what Convert.ToInt32() calls, anyway, isn't it ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Juan T. Llibre wrote:
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.


Session("whatever") is not a string, it's an "object".
You can't cast a string to an int (you have to "parse" it),
but you can cast an object to an int (if it really *is* an int).
So your solution *does* work...

--
Hans Kesting

Nov 19 '05 #9
Actually I think you'll find it's an int32 not a string, if you do:

Session("test") = 1

Dim a As String = Session("test").GetType.ToString

You'll see that a is System.Int32
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eC*************@TK2MSFTNGP12.phx.gbl...
Hello, Hans.

While the Session object is an object ( of course ),
its *content* can be a string, as in this particular case
...where the 1 in Session("passed") = 1 is a string, not an object.

This works, for example :

Session("passed") = 1
Dim yNumber as String = Session("passed")
Dim jNumber as Integer = Int32.Parse(yNumber)
Dim wNumber as Integer = jNumber + jNumber
lblMessage.Text = wNumber.ToString()

You're right about the use of "casting", though.
That was a bit sloppy on my part.

I should have used "Convert.ToInt32" or "Parse".

Int32.Parse() is what Convert.ToInt32() calls, anyway, isn't it ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Juan T. Llibre wrote:
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.


Session("whatever") is not a string, it's an "object".
You can't cast a string to an int (you have to "parse" it),
but you can cast an object to an int (if it really *is* an int).
So your solution *does* work...

--
Hans Kesting


Nov 19 '05 #10
Cool...

And Session("passed") = "1" 's type is ... ?

;-)

Question for you :

How does Session("passed") = 1
get converted from Int32 to String in
Dim yNumber as String = Session("passed")

Shouldn't that cause an "incorrect type" error ?

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
Actually I think you'll find it's an int32 not a string, if you do:

Session("test") = 1

Dim a As String = Session("test").GetType.ToString

You'll see that a is System.Int32
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eC*************@TK2MSFTNGP12.phx.gbl...
Hello, Hans.

While the Session object is an object ( of course ),
its *content* can be a string, as in this particular case
...where the 1 in Session("passed") = 1 is a string, not an object.

This works, for example :

Session("passed") = 1
Dim yNumber as String = Session("passed")
Dim jNumber as Integer = Int32.Parse(yNumber)
Dim wNumber as Integer = jNumber + jNumber
lblMessage.Text = wNumber.ToString()

You're right about the use of "casting", though.
That was a bit sloppy on my part.

I should have used "Convert.ToInt32" or "Parse".

Int32.Parse() is what Convert.ToInt32() calls, anyway, isn't it ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Juan T. Llibre wrote:
Because Session("passed") is a string.
Try casting to Int, and then adding 1 to it.

Session("whatever") is not a string, it's an "object".
You can't cast a string to an int (you have to "parse" it),
but you can cast an object to an int (if it really *is* an int).
So your solution *does* work...

--
Hans Kesting



Nov 19 '05 #11
Then it's a string, but there are no quotes in the example provided above.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ea*************@TK2MSFTNGP14.phx.gbl...
Cool...

And Session("passed") = "1" 's type is ... ?

;-)

Question for you :

How does Session("passed") = 1
get converted from Int32 to String in
Dim yNumber as String = Session("passed")

Shouldn't that cause an "incorrect type" error ?

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
Actually I think you'll find it's an int32 not a string, if you do:

Session("test") = 1

Dim a As String = Session("test").GetType.ToString

You'll see that a is System.Int32


"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eC*************@TK2MSFTNGP12.phx.gbl...
Hello, Hans.

While the Session object is an object ( of course ),
its *content* can be a string, as in this particular case
...where the 1 in Session("passed") = 1 is a string, not an object.

This works, for example :

Session("passed") = 1
Dim yNumber as String = Session("passed")
Dim jNumber as Integer = Int32.Parse(yNumber)
Dim wNumber as Integer = jNumber + jNumber
lblMessage.Text = wNumber.ToString()

You're right about the use of "casting", though.
That was a bit sloppy on my part.

I should have used "Convert.ToInt32" or "Parse".

Int32.Parse() is what Convert.ToInt32() calls, anyway, isn't it ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
Juan T. Llibre wrote:
> Because Session("passed") is a string.
> Try casting to Int, and then adding 1 to it.
>
>

Session("whatever") is not a string, it's an "object".
You can't cast a string to an int (you have to "parse" it),
but you can cast an object to an int (if it really *is* an int).
So your solution *does* work...

--
Hans Kesting



Nov 19 '05 #12
re:
Then it's a string, but there are no quotes in the example provided above.
I know...

Do you have any ideas about the question I asked ?

How does Session("passed") = 1
get converted from Int32 to String in
Dim yNumber as String = Session("passed")

Shouldn't that cause an "incorrect type" error ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl... Then it's a string, but there are no quotes in the example provided above.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ea*************@TK2MSFTNGP14.phx.gbl...
Cool...

And Session("passed") = "1" 's type is ... ?

;-)

Question for you :

How does Session("passed") = 1
get converted from Int32 to String in
Dim yNumber as String = Session("passed")

Shouldn't that cause an "incorrect type" error ?

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
Actually I think you'll find it's an int32 not a string, if you do:

Session("test") = 1

Dim a As String = Session("test").GetType.ToString

You'll see that a is System.Int32


"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eC*************@TK2MSFTNGP12.phx.gbl...
Hello, Hans.

While the Session object is an object ( of course ),
its *content* can be a string, as in this particular case
...where the 1 in Session("passed") = 1 is a string, not an object.

This works, for example :

Session("passed") = 1
Dim yNumber as String = Session("passed")
Dim jNumber as Integer = Int32.Parse(yNumber)
Dim wNumber as Integer = jNumber + jNumber
lblMessage.Text = wNumber.ToString()

You're right about the use of "casting", though.
That was a bit sloppy on my part.

I should have used "Convert.ToInt32" or "Parse".

Int32.Parse() is what Convert.ToInt32() calls, anyway, isn't it ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
> Juan T. Llibre wrote:
>> Because Session("passed") is a string.
>> Try casting to Int, and then adding 1 to it.
>>
>>
>
> Session("whatever") is not a string, it's an "object".
> You can't cast a string to an int (you have to "parse" it),
> but you can cast an object to an int (if it really *is* an int).
> So your solution *does* work...
>
> --
> Hans Kesting



Nov 19 '05 #13
Hmm, I think .net is just being friendly and automatically casting the int32
to a string for you. That's my guess anyway.

you get the same thing if you do:

Dim a As Int32 = 1

Dim b As String = a


"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u0**************@TK2MSFTNGP15.phx.gbl...
re:
Then it's a string, but there are no quotes in the example provided
above.


I know...

Do you have any ideas about the question I asked ?

How does Session("passed") = 1
get converted from Int32 to String in
Dim yNumber as String = Session("passed")

Shouldn't that cause an "incorrect type" error ?


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl...
Then it's a string, but there are no quotes in the example provided
above.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ea*************@TK2MSFTNGP14.phx.gbl...
Cool...

And Session("passed") = "1" 's type is ... ?

;-)

Question for you :

How does Session("passed") = 1
get converted from Int32 to String in
Dim yNumber as String = Session("passed")

Shouldn't that cause an "incorrect type" error ?

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Joseph Byrns" <jo*********@nnoossppaamm-yahoo.com> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
Actually I think you'll find it's an int32 not a string, if you do:

Session("test") = 1

Dim a As String = Session("test").GetType.ToString

You'll see that a is System.Int32
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eC*************@TK2MSFTNGP12.phx.gbl...
> Hello, Hans.
>
> While the Session object is an object ( of course ),
> its *content* can be a string, as in this particular case
> ...where the 1 in Session("passed") = 1 is a string, not an object.
>
> This works, for example :
>
> Session("passed") = 1
> Dim yNumber as String = Session("passed")
> Dim jNumber as Integer = Int32.Parse(yNumber)
> Dim wNumber as Integer = jNumber + jNumber
> lblMessage.Text = wNumber.ToString()
>
> You're right about the use of "casting", though.
> That was a bit sloppy on my part.
>
> I should have used "Convert.ToInt32" or "Parse".
>
> Int32.Parse() is what Convert.ToInt32() calls, anyway, isn't it ?
>
>
>
>
> Juan T. Llibre
> ASP.NET MVP
> http://asp.net.do/foros/
> Foros de ASP.NET en Español
> Ven, y hablemos de ASP.NET...
> ======================
>
> "Hans Kesting" <ne***********@spamgourmet.com> wrote in message
> news:uN**************@tk2msftngp13.phx.gbl...
>> Juan T. Llibre wrote:
>>> Because Session("passed") is a string.
>>> Try casting to Int, and then adding 1 to it.
>>>
>>>
>>
>> Session("whatever") is not a string, it's an "object".
>> You can't cast a string to an int (you have to "parse" it),
>> but you can cast an object to an int (if it really *is* an int).
>> So your solution *does* work...
>>
>> --
>> Hans Kesting
>
>



Nov 19 '05 #14

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

Similar topics

14
by: dale zhang | last post by:
Hi groups, Can anyone give me the equivalent C# sharp code for this VB.ET code, :: VB.NET :: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles...
0
by: phmyhn | last post by:
I have two web pages, one is viewlarger.aspx, another one is shoppingcart.aspx. On the viewlarger.aspx, when clicking "add to cart" image button, the sub appends the id (passed from another page...
1
by: Lauchlan M | last post by:
Hi. I'm using ASP.NET, getting an "Object reference not set to an instance of an object" error. In my login.aspx page I have: string arrUserRoles = new string {"UserRole"};...
0
by: dee | last post by:
Hi My code complies the following line: Session("passed") = 1 but puts wiggly error line under the second Session("passed") in the following expression: Session("passed") = Session("passed") +...
4
by: Paul W | last post by:
Hi - I don't want to rely on my users having cookies enabled. If I use Cookieless=True it of course mangles the urls which means there is no browser caching of the pages, so it is slow. ...
9
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated...
1
by: Feng | last post by:
Hi, Need help on the following issue. We need to clean up some session specific backend resource when a user ends his session. We have a "Logoff" button on the pages that handles that. But...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.