INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
Thanks so much for having a place for us propeller heads to hang out and chat.
Where in the world do Tek-Tips members come from?
Some Handy VBScript Functions
Posted: 30 Jan 03
Add or subtract a period of time from a given date. Period of time includes year, week, day, month, hour, minute, second.
newdate = dateadd("m",2,"10-Jan-95")
where m = timeperiod
2 = how many timeperiods
newdate would be + 2 months ie 10-Mar-95
-2 would be 2 months previously
Calculate differance between two dates. Result can be positive or negative. Good for determining if date is before/after another date.
if datediff("d",date1,date2) > 0 then
date2 is after date1
Find the presence of a string within another string. E.g. If you want to find a string in a file you can use this function within a loop and check everyline.
linestr = myfile.readline
if instr(linestr, "string we want") then
split a string into an array, by a delimiter. e.g. you can split lines from a CSV file by the ','
e.g. line in a file reads "thisvalue = 10"
myarray = split(linestr, "=")
valuewewant = myarray(1)
remember arrays start at zero
the size of an array. if want to cycle thru an array and you dont know how big it is
then u can do
for i = 0 to ubound(array)
myvalue = array(i)
Back to VBScript FAQ Index
Back to VBScript Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close