' ADIVINA ' 04-11-12 DECLARE SUB programa (Sender AS QBUTTON) DECLARE SUB reinicia (Sender AS QBUTTON) DECLARE SUB acaba (Sender AS QBUTTON) CREATE Form AS QFORM Caption = "Adivina" Width = 320 Height = 240 Center CREATE Label1 AS QLABEL Caption = "Introduce numero" Left = 23 Top = 46 Width = 104 Transparent = 1 END CREATE CREATE Label4 AS QLABEL Caption = "Llevas 0 intentos" Left = 23 Top = 66 Width = 104 Transparent = 1 END CREATE CREATE Label2 AS QLABEL Caption = "" Left = 101 Top = 98 Width = 136 Transparent = 1 END CREATE CREATE Label3 AS QLABEL Caption = "" Left = 117 Top = 130 Width = 128 Transparent = 1 END CREATE CREATE Button1 AS QBUTTON Caption = "&Intentalo" Left = 102 Top = 153 OnClick = programa END CREATE CREATE Button2 AS QBUTTON Caption = "&Reinicia" Left = 42 Top = 153 OnClick = reinicia Visible = 0 END CREATE CREATE Button3 AS QBUTTON Caption = "&Fin" Left = 192 Top = 153 OnClick = acaba END CREATE CREATE Edit1 AS QEDIT Text = "" Left = 157 Top = 40 TabOrder = 1 END CREATE END CREATE 'Insert your initialization code here 5 randomize 10 num = int (rnd (100)) 20 llevas = 0 Form.ShowModal '--------- Subroutines --------- SUB programa (Sender AS QEDIT) intento = val (edit1.text) llevas = llevas + 1 if intento > num then label4.caption = "Llevas " + str$ (llevas) + " intentos" label2.caption = "es menor que " + edit1.text edit1.text = "" end if if intento < num then label4.caption = "Llevas " + str$ (llevas) + " intentos" label2.caption = "es mayor que " + edit1.text edit1.text = "" end if if intento = num then label4.caption = "Lo has conseguido en " + str$ (llevas) + " intentos" label2.caption = "" label3.caption = "Has acertado!!" Button1.Visible = 0 Button2.Visible = 1 end if END SUB SUB reinicia (Sender AS QEDIT) num = int (rnd (100)) llevas = 0 label4.caption = "Llevas 0 intentos" label2.caption = "" label3.caption = "" Button1.Visible = 1 Button2.Visible = 0 END SUB SUB acaba (Sender AS QEDIT) end END SUB