sirolf_otrebla
15-11-2010, 14:49
innanzitutto salve a tutti! :)
qualche giorno fa ho iniziato a programmare in c# e ieri decisi di prerarare un cronometro visuale. secondo il compilatore non ci sono errori eppure quando apro l
il debug e premo il pulsante play il cronometro non parte e il form si blocca. potete aiutarmi?
ecco il codice:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int x = 10;
int min = 0;
int ss = 0;
int hh = 0;
string at = ":";
private void buttonpause_Click(object sender, EventArgs e)
{
x = 11;
}
private void buttonlay_Click(object sender, EventArgs e)
{
x = 10;
while (x == 10)
{
START23:
caselladitesto.Clear();
ss++;
caselladitesto.Text = caselladitesto.Text + hh;
caselladitesto.Text = caselladitesto.Text + at;
caselladitesto.Text = caselladitesto.Text + min;
caselladitesto.Text = caselladitesto.Text + at;
caselladitesto.Text = caselladitesto.Text + ss;
Thread.Sleep(1000);
if (ss == 60)
{
ss = 0;
min++;
goto START23;
}
if (ss < 60)
{
goto START23;
}
if (min == 60)
{
min = 0;
hh++;
goto START23;
}
}
}
private void buttonclear_Click(object sender, EventArgs e)
{
caselladitesto.Clear();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
il bello è che il codice in versione x console funziona a meraviglia!!
uso visual c# 2010 express. grazie in anticipo! :)
qualche giorno fa ho iniziato a programmare in c# e ieri decisi di prerarare un cronometro visuale. secondo il compilatore non ci sono errori eppure quando apro l
il debug e premo il pulsante play il cronometro non parte e il form si blocca. potete aiutarmi?
ecco il codice:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int x = 10;
int min = 0;
int ss = 0;
int hh = 0;
string at = ":";
private void buttonpause_Click(object sender, EventArgs e)
{
x = 11;
}
private void buttonlay_Click(object sender, EventArgs e)
{
x = 10;
while (x == 10)
{
START23:
caselladitesto.Clear();
ss++;
caselladitesto.Text = caselladitesto.Text + hh;
caselladitesto.Text = caselladitesto.Text + at;
caselladitesto.Text = caselladitesto.Text + min;
caselladitesto.Text = caselladitesto.Text + at;
caselladitesto.Text = caselladitesto.Text + ss;
Thread.Sleep(1000);
if (ss == 60)
{
ss = 0;
min++;
goto START23;
}
if (ss < 60)
{
goto START23;
}
if (min == 60)
{
min = 0;
hh++;
goto START23;
}
}
}
private void buttonclear_Click(object sender, EventArgs e)
{
caselladitesto.Clear();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
il bello è che il codice in versione x console funziona a meraviglia!!
uso visual c# 2010 express. grazie in anticipo! :)