?
Solved

Strange Error in FromOADate in Australia !

Posted on 2005-03-21
11
Medium Priority
?
480 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

762 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