?
Solved

Strange Error in FromOADate in Australia !

Posted on 2005-03-21
11
Medium Priority
?
489 Views
Last Modified: 2012-06-22
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "................

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dat As Date
        dat = System.DateTime.FromOADate(txt.Text)
        MsgBox("Date value is " & Format(dat, "dd-MMM-yyyy"))
    End Sub
End Class

txt have the value 72686 (corresponding to date 1/1/2099)

This works fine on my PC, but on a client in australia its coming back with

    Cast from string "72686" to type date is not valid

Any idea why ?
0
Comment
Question by:plq
  • 4
  • 4
  • 3
11 Comments
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13598754
What have they got there regional settings set to ie do they have it set to mm-dd-yyyy or dddd-mm-yyyy or what ? As that might affect it , not sure though :-S
0
 
LVL 8

Author Comment

by:plq
ID: 13598864
I asked them to check regional settings, they said they were aus standard.

There are several other aus customers who don't get this problem
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13598889
what exactly is aus standard ? Also how old is that clients computer because I know with old computers there was a data limitation or something to that extent I think, not positive on that though !
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13598905
I see you have it entered via a text box, are you sure they are entering it correctly into the textbox ? ie the slashes or hi fins, not sure what you call them lol ("-"  without quotes ) are inserted and they have not got any spaces when they enter it and they have entered it accordingly ie you have it so it is dd-mmm-yyyy, hence they would enter it something like "02-feb-2005" without quotes and no spaces ?
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13598909
Also what happens if they try a different value in the textbox as apposed to 72686 ??
0
 
LVL 8

Author Comment

by:plq
ID: 13599016
I had them try whatever number corresponds to 1/1/2010 and it was the same.

The original problem was from a string value read from a file. The text box is just part of a test program which reproduces the problem.
0
 
LVL 4

Expert Comment

by:wyoung76
ID: 13599030
I'm presuming this won't make the slightest bit of difference (since DateTime is just a wrapper for the Date data type), but you could eliminate this possibility as well.

Try changing this:

    Dim dat As Date

to this:

    Dim dat As System.DateTime
0
 
LVL 4

Expert Comment

by:wyoung76
ID: 13599039
Also, you could try doing System.DateTime.FromOADate(CDbl(txt.Text)) to see if it makes any difference too.
0
 
LVL 8

Author Comment

by:plq
ID: 13599052
Yes, I just noticed that in the msdn documentation. But the compiler would automatically do a cdbl wouldn't it

Due to time zone differences I won't be able to try any tests until about 7pm gmt tonight.
0
 
LVL 4

Accepted Solution

by:
wyoung76 earned 2000 total points
ID: 13599411
I'd assume that it would automatically do something similar to CDbl() when compiled, but no harm in trying.

Like others here, I don't have any problem getting the sample to work.
0
 
LVL 8

Author Comment

by:plq
ID: 13631564
Sorry no real explanation but the problem just went away without any kind of fix

Must've been something screwy in .net
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question