Results 1 to 4 of 4

Thread: Date and Time

  1. #1

    Thread Starter
    Fanatic Member JCScoobyRS's Avatar
    Join Date
    Oct 2002
    Location
    Some Mountain in Colorado
    Posts
    677

    Date and Time

    I need to be able to generate a number that is a 14 digit number in this format:

    My number is the number of 10,000 of a second from January 1st, 1900 and then append 2 random numbers to the end.

    Can someone help? I've never done anything like this. Thanks, Jeremy
    He who listens well, speaks well.

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    look up datediff --- that'll get you started.

  3. #3
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     'You only want to randomize once in your project
    5.     ' or your random #'s won't be random!
    6.     Randomize
    7. End Sub
    8. Private Sub Command1_Click()
    9.     Dim lngNumSeconds As Long
    10.     Dim dblTTSeconds As Double
    11.     Dim intRandom As Integer
    12.     Dim strMyNumber As String
    13.    
    14.     'get seconds for 01/01/1990 till now
    15.     lngNumSeconds = DateDiff("s", "01/01/1990", Now)
    16.     'convert that to 10,000 of seconds elapsed
    17.     dblTTSeconds = CDbl(lngNumSeconds) * 10000
    18.        
    19.     'now build this number (string)
    20.        
    21.     'we are going to add two digits so show at least
    22.     ' 12 digits, but only 12 digits!
    23.     strMyNumber = Format(Left(dblTTSeconds, 12), "000000000000") & Format(Int((Rnd(1) * 99) + 1), "00")
    24.        
    25.     MsgBox strMyNumber
    26. End Sub

    something like that?
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  4. #4

    Thread Starter
    Fanatic Member JCScoobyRS's Avatar
    Join Date
    Oct 2002
    Location
    Some Mountain in Colorado
    Posts
    677

    That works for me

    Thanks once again for your help. Later, Jeremy
    He who listens well, speaks well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width