Script to use user entered date フォローする
Howdy, this code nearly works, but still getting errors for some reason. This isn't my first rodeo - I've worked in VBA for years, but I haven't worked with VBS before. Working on a Windows 10 64bit desktop linked to Excel as database, printing on Zebra label printers. All the printing is existing and works as intended. Most of the code below is existing as well.
A print-time field defaults to today's date, and user has option to change. This is stored in an unprinted object on the label named "DateHelper". I need the script to test the DateHelper value and add an extra day if it is the sixth day of the week (Friday). Additionally, it needs to lookup against a database and add the "DAYS" field value. In quasi:
If DateHelper is a Friday, then return DateHelper + 1 + Field, if not Friday then return DateHelper + Field
DHvalue = Format.NamedSubStrings("DateHelper").Value
FreshDays = Field("DAYS")
FreshDaysLong = Field("DAYS") + 1
If Weekday(DHvalue) = 6 Then
Value = DateAdd("d", FreshDaysLong, DHvalue)
Value = DateAdd("d", FreshDays, DHvalue)
Most of the above is already working in production. The only change is using DHvalue to inherit from the field at print-time. In past the DHvalue predicate and value used Date to use system date.
I get an error as "Invalid procedure call or argument: 'DateAdd'. I have tested the variable FreshDaysLong and it indeed does return a numeric such as 11. When I call the DateAdd statement using a numeric, code executes without error. Why is the variable causing this to throw an error? Is it a data type issue? I've experimented with various forces of CDate(DHvalue) as well as CInt(FreshDaysLong) / Cdbl(FreshDaysLong), but I can't find the right combination.
Any advice? TY - DT