Results 1 to 8 of 8

Thread: Label question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Unhappy

    Ok lets say in label1.caption i have the time
    1:30:34

    now i have 3 more labels

    label2.caption
    label3.caption
    label4.caption
    I was label2.caption to read the 1
    label3.caption to read the 30
    and label label4.caption to read the 34

    So another words to be able to split the time apart in label1 into the 3 other labels....hours, minutes, and seconds......got me?

    If you can help leave a post...thanks!
    -RaY
    VB .Net 2010 (Ultimate)

  2. #2
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    Hi,

    if that's what I'am thinking, use the Hour, Minute, Second functions to get each parts separed like this :

    Label2.caption = hour(label1.caption)
    ...


    The time format of label 1 MUST be compatible with the time format of your PC for these functions to work OK.

  3. #3
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722
    Code:
    Public Sub SplitTime()
        Label1 = Format(Time,"hh:mm:ss")
        Label2 = Mid(Label1,1,2)
        Label3 = Mid(Label1,4,2)
        Label4 = Mid(Label1,7,2)
    End Sub
    Vince has a better one...

    [Edited by r0ach on 05-30-2000 at 06:11 PM]

    r0ach™
    Don't forget to rate the post

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Exclamation That wont work because

    This would not work because the time in label1.caption is not the actual time.....its a timer that is set to 2 hours and then counts down automatically before it goes back to form1...... So i need to be able to read the caption itself.

    -RaY
    VB .Net 2010 (Ultimate)

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    One Way

    Private Sub Command1_Click()

    'I've used 4,3,2,1 as labels

    Dim one, two, three, sTime As String

    sTime = Time

    Label4.Caption = Format(sTime, HH)

    one = Left(Time, 2)
    two = Mid(Time, 4, 2)
    three = Mid(Time, 7, 2)
    one = Format(one, "00")
    two = Format(two, "00")
    three = Format(three, "00")

    Label1.Caption = one
    Label2.Caption = two
    Label3.Caption = three

    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Addicted Member
    Join Date
    Jul 1999
    Location
    St-Élie d'Orford, Quebec, Canada
    Posts
    133
    it will work because the display format 1:30:30, 1:30:29...
    is a valid time format on your PC.

    If it doesn't work, put it in a temporairy datetime variable
    then use the functions.

    I did not tested this but I'am quite sure it work great...

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Smile Thanks guys

    Thanks everyone, Vince I would give that code a try as soon as i get off work...Thanks a lot man!
    -RaY
    VB .Net 2010 (Ultimate)

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Red face IT works vince

    vince da messiah
    -RaY
    VB .Net 2010 (Ultimate)

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