[Guida]Creare un Cronometro

Stato
Discussione chiusa ad ulteriori risposte.

Juck

Utente Silver
13 Dicembre 2008
120
9
7
81
Ultima modifica da un moderatore:
Ecco a voi il Source del mio Cronometro... :D

Codice:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Text = Date.Now
        Process.Start("http://forum.pescatoridelweb.altervista.org/forum/")
    End Sub

    Private Sub timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim seconds As Integer = Cronometro.Text.Substring(3, 2)
        Dim minutes As Integer = Cronometro.Text.Substring(0, 2)

        If seconds Mod 59 = 0 And seconds > 0 Then
            minutes += 1

            Cronometro.Text = Format(minutes, "00") & ":00"
        Else
            seconds += 1
            Cronometro.Text = Format(minutes, "00") & ":" & Format(seconds, "00")
        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If Button1.Text = "Start" Then
            Timer1.Enabled = True
            Label2.Text = "Ora Inizio:" & " " & TimeOfDay.Hour & ":" & TimeOfDay.Minute & ":" & TimeOfDay.Second
            Button1.Text = "Stop"
        Else
            Timer1.Enabled = False
            Label3.Text = "Ora Stop:" & " " & TimeOfDay.Hour & ":" & TimeOfDay.Minute & ":" & TimeOfDay.Second
            Label4.Text = "Tempo Trascorso:" & " " & Cronometro.Text
            Cronometro.Text = "00:00"
            Button1.Text = "Start"
        End If

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Button1.Text <> "Start" Then
            MsgBox("Attezione! Ferma il cronometro.", MsgBoxStyle.Critical)
            Exit Sub
        End If
        Label2.Text = "START"
        Label3.Text = "STOP"
        Label4.Text = "TEMPO TRASCORSO"
        Cronometro.Text = "00:00"
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Label1.Text = Date.Now
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Process.Start("http://forum.pescatoridelweb.altervista.org/forum/")
    End Sub
End Class
 
funziona tutto xo vb mi dice che ci sono errori di sintassi e ho controllato ma nn ce ne sono...
come faccio ad aprire un processo esterno allora??
 
Mmmmmm è molto strano... Ti dico cosa devi mettere nel Form così vedi se va:

1 TextBox
4 Label
1 LinkLabel
3 Button

Per i nomi rimangono gli stessi solo che la textbox si chiama Cronometro e come text ha 00:00

Per tutto il resto dovrebbe partire. Vedi adesso.
 
Stato
Discussione chiusa ad ulteriori risposte.