Results 1 to 7 of 7

Thread: Problems with the Format function

  1. #1

    Thread Starter
    Hyperactive Member Comreak's Avatar
    Join Date
    Feb 2001
    Location
    Dis
    Posts
    319

    Problems with the Format function

    I know this is a noob question but here goes:

    Here is a snippit of code:

    millsec = millsec + 1


    lblMilli.Text = millsec


    lblSeconds.Text = Format(millsec / 1000, "##")

    This code is inside a timer control with an interval of 1. As you can see, I'm trying to convert milliseconds to seconds by dividing
    millsec (which represents the number of milliseconds which have gone by) by 1000. I then try to format this number to only have two digits using the format function. Instead of having the seconds field go up one every 1000 millisecond it goes up one every 500 milliseconds. I get rid of the formating and everything works (with all the decimal places). I'm using an integer data type for millsec. I hope this isn't too much. Any help appreciated.

  2. #2
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Why not just set the timer .Interval to 1000, to make it tick over every second?
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  3. #3

    Thread Starter
    Hyperactive Member Comreak's Avatar
    Join Date
    Feb 2001
    Location
    Dis
    Posts
    319
    I'm a moron, always trying to do everything the hard way. Thanks, i'll try that.

  4. #4
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Originally posted by Comreak
    I'm a moron, always trying to do everything the hard way. Thanks, i'll try that.
    Moron = Someone who comes to the forum asking for help making a virus.

    Newbie = Someone who comes to the forum asking how to format milliseconds in a timer when there's an easier way.

    newbie doesn't necessarily equal moron.

  5. #5

    Thread Starter
    Hyperactive Member Comreak's Avatar
    Join Date
    Feb 2001
    Location
    Dis
    Posts
    319
    I suppose I'd rather be a newbie instead of a moron. I origonally wanted to show the passage of milliseconds, not just seconds. I still need a way to format milliseconds.

  6. #6
    New Member
    Join Date
    Apr 2002
    Location
    delhi
    Posts
    5
    hi
    may be this will help out

    Dim millSec As Integer
    Private Sub Timer1_Timer()

    millSec = millSec + 1

    Text1.Text = Format(millSec / 1000, ".###")
    End Sub
    u have 2 change the format which i have given u
    best of luck
    b bye
    Rishi Bhutani
    rishi

  7. #7

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