miércoles, 4 de noviembre de 2009

Código Formulario Menú

MENU
En este ejercicio utilizamos 3 formularios, Fmain (Menu), Form1 (Cronometro), Form2 (Juego).




MENU(FMain)
PUBLIC SUB Reloj_Click()
Form1.Show
END
PUBLIC SUB Juego_Click()
Form2.Show
END
PUBLIC SUB Yes_Click()
ME.Close
END

Cronometro(Form1)
En este formulario utilizamos 3 Label, 3 TextBox, 3 Button, 1 Timer.

PUBLIC s AS Integer
PUBLIC m AS Integer
PUBLIC h AS Integer
PUBLIC SUB Timer1_Timer()
s = TextBox1.Text
IF s < 59 THEN
s = s + 1
ELSE
IF m < 59 THEN
s = 0
m = m + 1
TextBox2.Text = m
ELSE
'horas
IF h < 23 THEN
m = 0
h = h + 1
TextBox3.Text = h
ELSE
' Timer1.Enabled = FALSE
' TextBox1.text = 0
' TextBox2.text = 0
' TextBox3.text = 0
s = 0
h = 0
m = 0
ENDIF
ENDIF
ENDIF
TextBox1.text = s
END
PUBLIC SUB Button1_Click()
IF Button1.Text = "Iniciar" THEN
Timer1.Enabled = TRUE
Button1.Text = "Parar"
ELSE
IF Button1.Text = "Parar" THEN
Timer1.Enabled = FALSE
Button1.Text = "iniciar"
ELSE
Timer1.Enabled = TRUE
Button1.Text = "Parar"
ENDIF
ENDIF
END
PUBLIC SUB Button2_Click()
IF Button2.Text = "Restaurar" THEN
Timer1.Enabled = FALSE
TextBox1.text = 0
TextBox2.text = 0
TextBox3.text = 0
s = 0
h = 0
m = 0
ENDIF
END
PUBLIC SUB Button3_Click()
ME.close
FMain.Show
END

Juego(Form2)
En este formulario utilizamos 1 Label, 3 TextBox, 3 Button, 1 Timer.

PUBLIC SUB Button1_Click()
Timer1.Enabled = TRUE
END
PUBLIC SUB Button2_Click()
ME.Close
FMain.Show
PUBLIC SUB Timer1_Timer()
DIM a, b, c AS Integer
RANDOMIZE
a = (Rnd * 10) + 1
TextBox1.Text = a
' Message("Este es el numero" & TextBox1.Text)
b = (Rnd * 10) + 1
TextBox2.Text = b
' Message("Este es el numero" & TextBox2.Text)
c = (Rnd * 10) + 1
TextBox3.Text = c
' Message("Este es el numero" & TextBox3.Text)
IF a = b AND b = c AND TextBox4.Text = a THEN
Message("Felicidades")
ENDIF
END
PUBLIC SUB Button3_Click()
Timer1.Enabled = FALSE
END

No hay comentarios:

Publicar un comentario