Results 1 to 10 of 10

Thread: Clock in VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    67

    Question Clock in VB6

    i need to do a clock that is in time with the system clock but has hours minutes and seconds and are in separate textboxes. can anyone help me out with the code?

    I saw that by the post by by mikeee they had this code


    Code:
          Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      
               TextBox1.Text = DateTime.Now.Hour.ToString
       
               TextBox2.Text = DateTime.Now.Minute.ToString
      
               TextBox3.Text = DateTime.Now.Second.ToString
      
          End Sub
    Here is the original post

    Now that code does not work on VB6. What can I do to put it on VB6?


    Also, How hard would it be to change a VB6 program to a VB2005 program? I have another program in VB6 that is basically buttons playing sounds using MMControl. How can I convert it to VB6?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Clock in VB6

    thats a vb6 question.

    to upgrade a vb6 project to .net, open it using .net
    there might be some upgrade issues you have to sort out

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Clock in VB6

    Thread Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Clock in VB6

    Another option:
    Code:
    txtHour.Text = Hour(Now)
    txtMin.Text = Minute(Now)
    txtSec.Text = Second(Now)

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Clock in VB6

    Quote Originally Posted by airman00
    Also, How hard would it be to change a VB6 program to a VB2005 program?
    You wouldn't change or convert it. You would totally rewrite it.

  7. #7

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Clock in VB6

    Quote Originally Posted by MartinLiss
    Doesn't Microsoft supply a conversion utility that will convert most of the code?
    They certainly do, however as always the problem with using any kind of wizard is reliability. I've yet to find one that is...
    So the verdict is [IMHO] - manually re-writing is much safer but of course it could be time consuming.

  9. #9
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Clock in VB6

    Want to watch the clock tick? Add a timer control:
    Code:
    Dim MyTime As String
    
    Private Sub Form_Load()
    Timer1.Interval = 200
    End Sub
    
    Private Sub Timer1_Timer()
    MyTime = Format$(Now, "hh:mm:ss")
    Text1.Text = Left$(MyTime, 2)
    Text2.Text = Mid$(MyTime, 4, 2)
    Text3.Text = Right$(MyTime, 2)
    End Sub
    Doctor Ed

  10. #10
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Clock in VB6

    Quote Originally Posted by MartinLiss
    txtHour.Text = Format(Now, "HH")
    txtMin.Text = Format(Now, "MM")
    txtSec.Text = Format(Now, "SS")
    MartinLiss, "MM" and "mm" is for Month. You have to use "nn" for Minute.
    However, you can use "hh:mm" for Hour:Minute.
    Last edited by anhn; Nov 5th, 2007 at 04:47 PM.

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