Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat May 27, 2017 10:02 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Convert VB to RB
PostPosted: Tue Nov 11, 2008 12:30 am 
Offline

Joined: Sat Jun 30, 2007 11:21 pm
Posts: 72
Location: Miami, Florida (USA)
I've written a utility to convert a file created with a program written in Visual Basic. Visual Basic has a Date type that I used to write some date info to the file.

Now I'm trying to convert the file and I need that Date information to be converted as well. The VB Date type uses a Double to represent the date and time information. I was hoping that I could assign this to the TotalSeconds property of the Date Class and it would work but it didn't. The values are different and I'm not sure how to parse out the VB date info.

Does anybody know a way I can convert this VB date data using Real Basic or how VB represents Date info in the Date type?

tc
-----------
REAL Basic r4.2
Windows Vista


Top
 Profile  
 
 Post subject: Re: Convert VB to RB
PostPosted: Tue Nov 11, 2008 3:57 am 
Offline
User avatar

Joined: Sun Oct 26, 2008 2:18 pm
Posts: 157
Location: San Francisco, CA
Sorry, no ideas (newbie in programming here) but i'm interested in your converter.. Can it really convert my VB projects to RB projects..? when is it going to be ready?

_________________
http://www.QueenZSoftware.com/


Top
 Profile  
 
 Post subject: Re: Convert VB to RB
PostPosted: Wed Nov 12, 2008 3:20 pm 
Offline
User avatar

Joined: Wed Nov 15, 2006 3:50 pm
Posts: 2353
Location: England
Off the top of my head, I think its a baseline problem.
The question you need to ask is 'what date is 0.000' in VB, and 'what date is 0.00' in RB's datetime.

Quick testing in VB using this code
Dim d As Date
MsgBox Format(CDate(0), "dd/mm/yyyy") '30th Dec 1899
MsgBox Format(Now(), "0.00000000") '39764.6576252


shows that ground zero in VB is effectively 01/01/1900
And that today is 39764.something

I did a bit of digging and found that Microsoft at least has two systems of date accounting in Excel.
1900 for compatibility with MSDOS, and 1904 for compatibility with Mac programs, which started counting in 1904 to 'avoid' having to account for 1900 as a leap year. (It says here...:> )

The difference between the two date systems is 1,462 days; that is, the serial number of a date in the 1900 Date System is always 1,462 days greater than the serial number of the same date in the 1904 date system. 1,462 days is equal to four years and one day (including one leap day).

You may therefore be on the right lines, but 1462 days out in the calc...


Top
 Profile  
 
 Post subject: Re: Convert VB to RB
PostPosted: Mon Nov 17, 2008 11:44 pm 
Offline

Joined: Sat Jun 30, 2007 11:21 pm
Posts: 72
Location: Miami, Florida (USA)
Thanks for your help on this. What I ended up doing was using a 2 step approach instead of 1 step. I used VB to convert the Date variable to a couple of strings, one for the date and one for the time. I wrote these to a file that I later converted using RealBasic and the ParseDate function.

This did the trick, but again thanks for the info.

tc


Top
 Profile  
 
 Post subject: Re: Convert VB to RB
PostPosted: Sat Jan 03, 2009 7:58 am 
Offline

Joined: Sat Oct 01, 2005 5:13 am
Posts: 603
Location: Shanghai, China
If you see some code like this in VB:
Dim d as Date
d=CDate(x) ' x is a double

You need convert it to RB like this:
Dim d as Date=new date
d.Year=1899
d.Month=12
d.Day=30
d.Hour=0
d.Minute=0
d.Second=0
d.TotalSeconds=d.TotalSeconds+x*86400

_________________
ToringoCrypto Plugin - RSA (128 to 1024), DES/3DES/TDEA, etc.
ToringoDRMInfo Plugin - Uniquely identify computers via hardware information.
【My Company: Are you looking for someone to help you work on your projects?


Top
 Profile  
 
 Post subject: Re: Convert VB to RB
PostPosted: Wed Jan 07, 2009 12:27 am 
Offline

Joined: Sat Jun 30, 2007 11:21 pm
Posts: 72
Location: Miami, Florida (USA)
Hey Zhu,

Thanks so much for finding my post and responding. I used your code and it worked perfectly allowing me to eliminate the extra step of doing a quasi-conversion with VB. This makes my project update task a lot eaiser.

Thanks again, and Happy New Year!

tc


Top
 Profile  
 
 Post subject: Re: Convert VB to RB
PostPosted: Fri Jun 08, 2012 12:26 am 
Offline

Joined: Sat May 05, 2012 11:04 pm
Posts: 11
Location: PH
Now how can you convert the date to double?

Since vb6 Cdbl also works with date and RB does not allow that.

_________________
My Website
http://silentprojectsoftwares.com/
Programming Language
Visual Basi 6.0 SP6 (Primary)
Real Studio 2011r4 (Still Testing)
Development Machine
Windows XP SP3
Other OS using VMWare
Windows XP SP2, Windows Vista, Windows 7 (32 and 64), Ubunto Linux, Max OS X


Top
 Profile  
 
 Post subject: Re: Convert VB to RB
PostPosted: Fri Jun 08, 2012 2:32 am 
Offline

Joined: Sat Oct 01, 2005 5:13 am
Posts: 603
Location: Shanghai, China
jhai_salvador wrote:
Now how can you convert the date to double?

Since vb6 Cdbl also works with date and RB does not allow that.


Simply using d.TotalSeconds to return the double.

_________________
ToringoCrypto Plugin - RSA (128 to 1024), DES/3DES/TDEA, etc.
ToringoDRMInfo Plugin - Uniquely identify computers via hardware information.
【My Company: Are you looking for someone to help you work on your projects?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group