Darkejo1
asked on
Converting String to Int in .vbs
I'm somewhat new to the coding world so bare with me...
Since today is the 11th, the "integer" variable should read as 12. I've tried to convert the string to an integer with newDate=CInt(Integer), but was unsuccessful. What am I doing wrong here?
newDate=Split(date,"/")
Integer=newDate(1) + 1
Since today is the 11th, the "integer" variable should read as 12. I've tried to convert the string to an integer with newDate=CInt(Integer), but was unsuccessful. What am I doing wrong here?
Can you post more of your code? Most importantly, please show where and how your variables (newDate and Integer) are declared.
This may help:
http://www.w3schools.com/vbscript/vbscript_variables.asp
http://www.w3schools.com/vbscript/vbscript_variables.asp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sure. Date was never declared. I'm going to assume it's a system variable. I'm not even allowed to redefine date.
This is what i get when I run it...
10/11/2011
11
11 (This is where I should get 11)
Dim newDate
Dim Integer
newDate=Split(date,"/")
Integer=newDate(1) + 1
Response.write date
Response.write newDate(1)
Response.write newDate(1) + 1
This is what i get when I run it...
10/11/2011
11
11 (This is where I should get 11)
ASKER
Oops, Should get 12 from the output of line 7..
If you always want to get tomorrow's day number:
MyResult = Day(Date + 1)
The Day function already returns a Long. If it must be an Int:
MyResult = CInt(Day(Date + 1))
MyResult = Day(Date + 1)
The Day function already returns a Long. If it must be an Int:
MyResult = CInt(Day(Date + 1))
The variable "Integer" I'm sure will cause problems eventually, I suggest changing it to something more descriptive. At any rate the word "Integer" is usually a reserved word in most programming languages and as such should be avoided as a variable name.
ASKER
Thanks, Sl8rz. I found that out when trying to assign Integer. I didn't use that in my code, I was just using that for demonstrative purposes and testing.