PDA

View Full Version : Accessing VB functions


AndyChamp
05-12-2005, 08:00 AM
I want to use VBScripts' DateDiff function to get the current day as number of days from a base date. This will be a field in our version number. However, although I can access the Year & Day functions, I can't get DateDiff. Is there aa list anywhere of which functions I can use?

kinook
05-12-2005, 09:34 AM
DateDiff is available from VBScript. The following code works in a Run Script step:

Builder.LogMessage DateDiff("d", Now, #1/1/2006#)

The available VBScript functions are documented here:
http://msdn.microsoft.com/library/en-us/script56/html/vtoriVBScript.asp

AndyChamp
05-12-2005, 09:47 AM
OK, that helps - but as a VBScript novice I'm still stuck!

The output I'm getting is now

Building project step 'Increment Build number'...
234
497
Error at Line 5, Column 1 (Object required: 'DateDiff(...)')

The script fragment is

' set the version number for the various features
Builder.LogMessage DateDiff("d", Now, #1/1/2006#)
'Set Origin = DateValue("1/1/2004")
Builder.LogMessage DateDiff("d", #1/1/2004#, Now)
set ourday = DateDiff("d", #1/1/2004#, Now)

It looks rather as if, despite the error complaining about DateDiff, it's some kind of type incompatibility. Any more help please?

kinook
05-12-2005, 09:52 AM
Remove the set in the line

set ourday = DateDiff("d", #1/1/2004#, Now)

The Set statement is used only when assigning object values (a VB-ism). DateDiff just returns a number.

AndyChamp
05-12-2005, 10:52 AM
That's it, thanks very much!

(I knew there was a good reason why I never use VB)