Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 12th, 2008, 11:49 PM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Bangkok, , Thailand.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Odd InputBox error

Can anyone please explain the following weird inconsistency??? My Regional Setting is confirmed as (Short Date): dd/mm/year so why does this happen when i run the script below??

Wscript.Echo Date 'Shows: 13/06/2008
strValue = InputBox("Enter Start Date:","Test", Date) 'Shows: 06/13/2008 in the box.
Wscript.Echo Date 'Shows: 13/06/2008

Any DateAdd calculation only happens on the (incorrect) "06/13/2008" value.


Reply With Quote
  #2 (permalink)  
Old June 13th, 2008, 01:27 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Looks like a bug to me!

Obviously, the simple WScript.Echo is paying attention to the Locale and is giving you the DD/MM/YYYY format you expect.

But for some reason INPUTBOX is ignoring the locale.

What you *MIGHT* try is converting the date to string *before* passing it to the inputbox.

Humor me and try this:

today = CStr(Date())
Wscript.Echo today
strValue = InputBox("Enter Start Date:","Test", today)
Wscript.Echo today

It may be wrong--it might always show MM/DD/YYYY--but at least it should be consistent.

Reply With Quote
  #3 (permalink)  
Old June 13th, 2008, 11:09 PM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Bangkok, , Thailand.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK Thanks a lot for that. To add to the mystery this only happens on [u]some</u> computers (not this one). I will try your suggestion when I get back to the apartment and let you know on Monday. Thanks again.
Reply With Quote
  #4 (permalink)  
Old June 15th, 2008, 10:50 PM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2008
Location: Bangkok, , Thailand.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is even weirder:

Wscript.Echo Date 'Shows 14/06/2008
Wscript.Echo Date & " " & Cstr(Date()) 'Now shows 06/14/2008 06/14/2008 !!!
todayStr = Cstr(date())
Wscript.Echo todayStr 'Says 06/14/2008
strValue = InputBox("Enter Start Date:","Test", todayStr)
Wscript.Echo todayStr 'Says 06/14/2008

All very, very odd!
Reply With Quote


Similar Threads
Thread Thread Starter Forum Replies Last Post
odd error with apply-templates select="..." name Fitty XSLT 1 January 18th, 2008 03:45 AM
Odd arithmetic overflow error.... 7racer SQL Server 2000 4 May 12th, 2006 09:17 AM
odd FF error, IE does nothing when run. JustABob Javascript 4 November 29th, 2005 01:50 PM
Inputbox and Formulas bahachin Excel VBA 3 February 17th, 2005 01:39 AM
InputBox Misbehaving bph Access 10 March 4th, 2004 01:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.