Results 1 to 5 of 5

Thread: Damn time variable.... *RESOLVED*

  1. #1

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718

    Damn time variable.... *RESOLVED*

    Hey peeps.

    I've just moved from VB6, and it seems half the standard variables don't work anymore!!!

    I'm trying to format the contents of a textbox to time format, like this...

    textbox.text = format(time, "h:mm")

    and all I get is "time not declared"....

    Any ideas, cause i'm not firing on all cylinders 2nite
    Last edited by VisionIT; Mar 11th, 2004 at 05:40 PM.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2001
    Location
    Houston, TX
    Posts
    342
    Try this..

    TextBox.Text=Format(Now, "hh:mm")

    HTH

  3. #3

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    Thanx... but i've tried that, and all it does it put the time in the text box

    I'm really confused!

    Say I have "21.5" in the text box, which obviously makes no sense like that, so I need it to read as "21 hours 30 minutes" etc etc

    Thanx

  4. #4
    Hyperactive Member
    Join Date
    Feb 2001
    Location
    Houston, TX
    Posts
    342
    Ahh, I see what your're trying to do.

    Try this one.

    (I am using a constant as the time but you can cdbl(Textbox.Text))

    Code:
    Const cTime As Double = 21.5
    
            Dim ts As New TimeSpan
            Dim t As DateTime
            Dim sTime As New System.Text.StringBuilder
    
            t = ts.FromHours(cTime).ToString
    
            sTime.Append(t.Hour & " Hours ")
            sTime.Append(t.Minute & " Minutes ")
    
            TextBox1.Text = sTime.ToString

  5. #5

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    That works nicely, cheers.

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