Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

vb clock

Options
  • 31-08-2002 10:48am
    #1
    Registered Users Posts: 3,299 ✭✭✭


    how do i get the current time inserted into a label ??? using VB


Comments

  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    It's a tough one that :p
    Label.Caption = Time
    

    ;-phobos-)


  • Registered Users Posts: 3,299 ✭✭✭irishguy


    thats what i taught but it comes up method or data type not found


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    What version are you using?

    Also go in to (Menu) Project/References, and see if "Visual Basic Runtime Objects & Procedures" is checked for use. If that doesn't work also check "Visual Basic Objects & Procedures".

    I'm pretty sure Time is in one of those DLLs. I could be wrong. Coz all I had to do here is bang in that code, and it worked, so my references were already setup. I'm using the Enterprise version of VB6 BTW

    ;-phobos-)


  • Registered Users Posts: 3,299 ✭✭✭irishguy


    its visual studio 6 enterprise edition,i tryed them and it still didnt work dont know what is wrong wit it


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    I'm sorry man, I retract my quick witted answer above, and join you in the line of curiosity.

    Kealan (Kayos) is proabably your best bet in answering this one quickly. He hasn't been toying with VB for a while AFAIK, but he's quite knowledgable in general area. Send him a nice PM or something, and I'm sure he'll oblige.

    ;-phobos-)


  • Advertisement
  • Registered Users Posts: 2,781 ✭✭✭amen


    your looking for
    Now()

    gives that date/time

    Date just gives the date

    e


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    The first thing I thought of was the Now() function, but I wouldn't be surprised if that didn't work for him either. I'd say all those date/time methods are located in the same place, and are somehow not refferenced by his current project.

    ;-phobos-)


  • Registered Users Posts: 3,299 ✭✭✭irishguy


    i got it ,it was text1.txt=time() it wasnt working cus i was using a control arrey


  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    OK, It was a completely different problem from what I was trying to tackle, but nevertheless you got it working. Good stuff :)

    ;-phobos-)


  • Registered Users Posts: 2,494 ✭✭✭kayos


    Originally posted by phobos
    I'm sorry man, I retract my quick witted answer above, and join you in the line of curiosity.

    Kealan (Kayos) is proabably your best bet in answering this one quickly. He hasn't been toying with VB for a while AFAIK, but he's quite knowledgable in general area. Send him a nice PM or something, and I'm sure he'll oblige.

    ;-phobos-)


    Jeeessss someone saying I'm good at VB cheers Weston ;).

    Any way sorry I didnt see your question earlier.

    kayos


  • Advertisement
  • Registered Users Posts: 1,393 ✭✭✭Inspector Gadget


    ...I tinker with VB a little bit (VBA actually, within Access - am helping out a friend of mine with some databases). As a subtle note, Now() returns the current date and time, formatted according to your locale settings (an example would be "03/09/2002 17:11:03"), whereas Now() will only return the current time ("17:11:03").

    A useful function to be aware of is Format() - you can use this to present the time or date any way you like. The {formatstring} parameter allows this control. The syntax is a follows:

    Format({variable}, {formatstring})

    A couple of quick examples:

    Format(Now, "hh:nn:ss") will give the time in the 24hr clock ("17:11:03")

    Format(Now, "h:nn AM/PM") will give the time in 12hr format ("5:11 PM")

    ...and so on. Look for "Format" and "User-Defined Date/Time Formats (Format Function)" in the help.

    Hope this helps...
    Gadget.


  • Registered Users Posts: 3,299 ✭✭✭irishguy


    i got the time insertion thing working now i just need 2 know how to calculate the differience between the 2 times,to the nearst miniute.you realy do forget alot over the summer :D


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by irishguy
    i got the time insertion thing working now i just need 2 know how to calculate the differience between the 2 times,to the nearst miniute.you realy do forget alot over the summer :D

    I would imagine that datediff would be yer man there.


    jc


  • Registered Users Posts: 3,299 ✭✭✭irishguy


    u are going 2 have 2 be more spefic there as my knowlage of vb is very limited and i havent done any programing for the last 6months


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Search for help on a function called datediff.

    How more specific do you need?


Advertisement