469,286 Members | 2,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

VB.Net Date Serial?

sam
Possible convert VB 6 to VB.Net 1.1 for date serial function?
Example, Calendar_Date = DateSerial(1900+(Julian_Date/1000), 1,Julian_Date
Mod 1000) ?

Calendar_Date and Julian_Date are input variable.

Please advise.

Many thanks.
Nov 21 '05 #1
4 11103
sam wrote:
Possible convert VB 6 to VB.Net 1.1 for date serial function?


DateSerial is still supported in VB.NET 1.1. If you can't get it working,
try this:

\\\
Calendar_Date = Microsoft.VisualBasic.DateSerial(1900+(Julian_Date/1000),
1,Julian_Date Mod 1000)
///

If that's not working either, what error message do you get?

--

(O) e n o n e
Nov 21 '05 #2
"sam" <sa*******@ajikl.com.my> schrieb:
Possible convert VB 6 to VB.Net 1.1 for date serial function?


VB.NET still supports 'DateSerial'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3
sam
I have an error message during perform dateserial in VB.Net 1.1 based on my
coding as shown as below:

Coding
-------
Imports System
Imports System.Data
Imports Microsoft.VisualBasic

Dim Inv_Date, GL_Date, InvDte,GLdte As Double

InvDte = CDbl(InvDte)
GLdte = CDbl(GLdte)

ADO Connection.....
Try
Do While dbrRD_F0411B.Read
InvDte = CDbl(dbrRD_F0411B("RPDIVJ"))
GLdte = CDbl(dbrRD_F0411B("RPDGJ"))

GL_Date = DateSerial(1900+(GLdte/1000), 1,GLdte Mod 1000)
Inv_Date= DateSerial(1900+(InvDte/1000),1,InvDte Mod 1000)
Loop
End Try

Error Message
---------------
BC30532 : Conversion from 'Date' to 'Double' requires caling the
'Date.ToOADate' method

Please advise.

Many thanks.
"Oenone" <oe****@nowhere.com> wrote in message
news:dN**************@newsfe1-win.ntli.net...
sam wrote:
Possible convert VB 6 to VB.Net 1.1 for date serial function?


DateSerial is still supported in VB.NET 1.1. If you can't get it working,
try this:

\\\
Calendar_Date = Microsoft.VisualBasic.DateSerial(1900+(Julian_Date/1000),
1,Julian_Date Mod 1000)
///

If that's not working either, what error message do you get?

--

(O) e n o n e

Nov 21 '05 #4
sam wrote:
I have an error message during perform dateserial in VB.Net 1.1 based
on my coding as shown as below:
[...] Dim Inv_Date, GL_Date, InvDte,GLdte As Double
GL_Date = DateSerial(1900+(GLdte/1000), 1,GLdte Mod 1000)

[...]

Ah, that's not a problem with DateSerial, that's a problem with variable
typing.

In VB6, dates were stored as Double values so you could directly assign a
Date to a Double variable.

In VB.NET, dates have their own distinct type (Date) and you can't directly
convert between them.

If you want to do what you're doing above, you will need to either:

1. Change your GL_Date (and probably your other variables too) to be defined
As Date instead of As Double. However, this will most likely break your
dbrRD_F0411B calls as they presumably return Double values too. You'll need
to change these to also return Date values.

2. Alternatively, leave your variables as Doubles and use the OLE Automation
Date conversion functions. These two methods are defined against the Date
class are can be used to convert a value from a Date to a Double (the
ToOADate() function) or from a Double to a Date (the FromOADate() function).

\\\
'Convert Date to a Double
GL_Date = DateSerial(2005,5,30).ToOADate

'Convert Double back to a Date
Dim d As Date = Date.FromOADate(GL_Date)
///

Hopefully that'll set you off in the right direction.

--

(O) e n o n e
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by diablo | last post: by
4 posts views Thread by Daniel Kaseman | last post: by
6 posts views Thread by Trekmp | last post: by
3 posts views Thread by Glencannon4424 via AccessMonster.com | last post: by
4 posts views Thread by Peter | last post: by
1 post views Thread by Graham Feeley | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.