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 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
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
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
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
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
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
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
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
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
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
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
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
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 > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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"};...
|
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") +...
|
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.
...
|
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...
|
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...
|
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"...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |