• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

Converting String to Int in .vbs

I'm somewhat new to the coding world so bare with me...

newDate=Split(date,"/")
Integer=newDate(1) + 1

Open in new window


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?
0
Darkejo1
Asked:
Darkejo1
1 Solution
 
David L. HansenProgrammer AnalystCommented:
Can you post more of your code?  Most importantly, please show where and how your variables (newDate and Integer) are declared.
0
 
David L. HansenProgrammer AnalystCommented:
0
 
Bill PrewCommented:
Try this

newDate=Split(date,"/")
Integer=CInt(newDate(1)) + 1

Open in new window

~bp
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Darkejo1Author Commented:
Sure. Date was never declared. I'm going to assume it's a system variable. I'm not even allowed to redefine date.

Dim newDate
Dim Integer
newDate=Split(date,"/")
Integer=newDate(1) + 1
Response.write date
Response.write newDate(1)
Response.write newDate(1) + 1

Open in new window


This is what i get when I run it...

10/11/2011
11
11 (This is where I should get 11)





0
 
Darkejo1Author Commented:
Oops, Should get 12 from the output of line 7..
0
 
Patrick MatthewsCommented:
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))
0
 
David L. HansenProgrammer AnalystCommented:
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.
0
 
Darkejo1Author Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now