You are not logged in.

A1880

Intermediate

  • "A1880" is male
  • "A1880" started this thread

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

1

Sunday, July 26th 2009, 2:10pm

Format and Timer

Hi,
in VB6 "Format" is a handy function to format date/time strings and numeric strings.
The current implementation in Jabaco is limited to dates and does not really work.
"Timer" is a useful function returning the time since mindnight in seconds.

My current experimental version:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Public Function Format(x As Double, fmt As String) As String
   Dim df As New java#text#DecimalFormat(fmt)
   
   Format = df.format(x)
End Function

Public Function Format(d As Date, fmt As String) As String
   Dim df As New java#text#SimpleDateFormat(fmt)
   
   Format = df.format(d)
End Function

Public Function Timer() As Single 
   Dim cal As Calendar = java#util#Calendar.getInstance()
   Dim hh As Integer = cal.get(java#util#Calendar.HOUR)
   Dim mm As Integer = cal.get(java#util#Calendar.MINUTE)
   Dim ss As Integer = cal.get(java#util#Calendar.SECOND)
   Dim ms As Integer = cal.get(java#util#Calendar.MILLISECOND)
   
   Timer = 0.001 * ms + ss + 60.0 * (mm + 60.0 * hh)
End Function


It would be nice, to have a VB6 compliant "Format".

Cheers!

A1880

This post has been edited 1 times, last edit by "A1880" (Jul 26th 2009, 7:39pm)


Rate this thread
WoltLab Burning Board