Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    [VB .NET] Evento tick, perchè errore?

    Ho un form con un timer e un bottone. Il codice non mi segna erroe tranne che nell'event handler tick, sicuramente non ho importato qualkosa credo... mi potet aiutare?

    codice:
    Imports System.Timers.Timer
    
    Public Class Form1
    
        Inherits System.Windows.Forms.Form
    
    .....
    
    Private Sub InitializeTimer()
            ' Run this procedure in an appropriate event.
            ' Set to 1 second.
            Timer1.Interval = 1000
            ' Enable timer.
            Timer1.Enabled = True
            Button1.Text = "Enabled"
        End Sub
    
        Private Sub Timer1_Tick(ByVal Sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
    ' Quì a questo tick mi dà errore
            ' Set the caption to the current time.
            Label1.Text = DateTime.Now
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If Button1.Text = "Stop" Then
                Button1.Text = "Start"
                Timer1.Enabled = False
            Else
                Button1.Text = "Stop"
                Timer1.Enabled = True
            End If
        End Sub
    End Class

  2. #2
    Utente di HTML.it L'avatar di Brainjar
    Registrato dal
    Nov 2004
    Messaggi
    1,162
    Quale errore ti da' e, soprattutto, su quale istruzione ?

    Ciao,
    Brainjar,.
    Ciao, Brainjar

  3. #3
    Si l'avevo scritto così piccolo che non si leggeva, asd

    L'errore me lo dà sul tick di questo Handles

    Private Sub Timer1_Tick(ByVal Sender As Object, ByVal e As EventArgs) Handles Timer1.Tick

    Mi sottolinea il .Tick

    Forse manca qualke libreria o qualke imports?

  4. #4
    Utente di HTML.it L'avatar di biste
    Registrato dal
    Apr 2001
    Messaggi
    877
    Timer1 di che tipo è?
    Se è di tipo System.Timers.Timer allora questo non ha un evento Tick, ma un evento Elapsed che però riceve un ElapsedEventArgs come argomento.
    Credo tu abbia cambiato il tuo Timer da System.Windows.Forms.Timer a System.Timers.Timer e hai creato un po' di confusione con il codice
    UGIdotNET
    Microsoft .NET MCAD
    C++, C#, VB6, VB.NET, ASP, ASP.NET
    SQL Server 2000

  5. #5
    Il problema è questo, volevo fare un cronometro, un countdown per l'esattezza, sul forum tutti i pezzi di codice trovati sono a metà e non completi, così o preso questo direttamente da msn, ma non và perkè mi dà un errore su tick.

  6. #6
    Utente di HTML.it L'avatar di cassano
    Registrato dal
    Aug 2004
    Messaggi
    3,002
    fai come ha detto biste dovrebbe essere quella la causa.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.