none
Digital clock Pictures RRS feed

  • Question

  • Hello honourable people, 

    I am new when it comes to programming and I will need all of you. Currently I want to create a digital clock that displays different piece of art every 30seconds. All I could do was add a picturebox and and a timer. I am stuck. Any help? I am using VISUAL BASIC 2012. Thanks.

    Wednesday, June 19, 2019 6:47 PM

All replies

  • Hello honourable people, 

    I am new when it comes to programming and I will need all of you. Currently I want to create a digital clock that displays different piece of art every 30seconds. All I could do was add a picturebox and and a timer. I am stuck. Any help? I am using VISUAL BASIC 2012. Thanks.

    Hi

    It will take while for all 28771 members to get around to answering your call to arms. Probably take you longer to read them all.


    Regards Les, Livingston, Scotland


    • Edited by leshay Wednesday, June 19, 2019 7:22 PM
    Wednesday, June 19, 2019 6:51 PM
  • Hi Leshay,

    Could you begin the process for me. Just provide me a sample code and I will understand and move on from there.

    Thanks for your incoming reply.

    For the timer 30seconds would be =30000milliseconds

    I also know that to load an image I need to import: system.drawing.image 

    And everything continues from there. Can you help me now?

    Wednesday, June 19, 2019 7:48 PM
  • Hi

    Here is some starter code for you.

    ' Form1 with PictureBox1
    Option Strict On
    Option Explicit On
    Public Class Form1
    	' set this path string to an
    	' Image folder path
    	Dim path As String = "C:\Users\lesha\Desktop\Plans\Dice 2"
    	Dim ListOfImages As New List(Of String)
    	Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    		PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
    
    		ListOfImages = IO.Directory.GetFiles(path, "*.png").ToList
    
    		' adjust Timer Interval to suit
    		Timer1.Interval = 500
    		Timer1.Enabled = True
    	End Sub
    
    	Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    		Static position As Integer = 0
    		PictureBox1.Image = Image.FromFile(ListOfImages(position))
    		position += 1
    		If position > ListOfImages.Count - 1 Then position = 0
    	End Sub
    End Class


    Regards Les, Livingston, Scotland

    Wednesday, June 19, 2019 8:14 PM
  • Hi,

    What is changed every 30 seconds? Image, font, or background color?

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim timer1 As New Timer With {.Enabled = True, .Interval = 100}
            Dim timer2 As New Timer With {.Enabled = True, .Interval = 30000}
            Dim MyBrush As SolidBrush = New SolidBrush(Color.Black)
            Dim gp As Graphics = PictureBox1.CreateGraphics
            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
            Dim MyImage As Image = ImageList1.Images(New Random().Next(0, ImageList1.Images.Count))
            AddHandler timer1.Tick, Sub()
    
                                        gp.Clear(Form1.DefaultBackColor)
                                        Dim strtime As String = DateTime.Now.ToString("HH:mm:ss")
                                        gp.DrawString(strtime, New Font("Arial", 15, FontStyle.Bold), MyBrush, 10, 10)
                                    End Sub
            AddHandler timer2.Tick, Sub()
                                        Dim R As Integer = New Random().Next(255)
                                        Dim G As Integer = New Random().Next(255)
                                        Dim B As Integer = New Random().Next(255)
                                        B = If((R + G > 400), R + G - 400, B)
                                        B = If((B > 255), 255, B)
                                        MyBrush = New SolidBrush(Color.FromArgb(R, G, B))
                                        MyImage = ImageList1.Images(New Random().Next(0, ImageList1.Images.Count))
                                    End Sub
        End Sub
    End Class

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 20, 2019 5:54 AM
  • Hi LesHay,

    Indeed you are a retired programmer, your code works like magic. Thank you so much. Much love and respect.

    Thursday, June 20, 2019 9:18 PM
  • Hi LesHay,

    Indeed you are a retired programmer, your code works like magic. Thank you so much. Much love and respect.

    Hi,

    Is your problem solved? If so, please mark the useful replies as answers.  

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 24, 2019 1:07 AM