Programas Gambas

8,377 views

Published on

Published in: Education, Technology, Business
  • Be the first to comment

Programas Gambas

  1. 1. EJERCICIOS “GAMBAS”<br />(BAJO CONSOLA)<br />EJERCICIO 1<br />“HOLA MUNDO”<br />140398550800<br />PUBLIC SUB Main()PRINT " HOLA MUNDO " PRINT " SOY STALIN RODRIGUEZ" END<br />EJERCICIO 2<br />“SUMA”<br />147066035560<br />PUBLIC SUB Main()‘Mi primera sumaDIM A AS IntegerDIM B AS IntegerDIM S AS IntegerA = 10B = 20S = A + BPRINT " LA SUMA ES...:" PRINT SEND<br />EJERCICIO 3<br />“MAYOR DE 3”<br />119316555245<br />'entre 3 números averiguar cual es el mayor<br />'el menor y el intermedio.<br />PUBLIC SUB Main()<br />DIM A, B, C AS Integer<br />A = 6<br />B = 10<br />C = 80<br />IF A > B AND A > C THEN <br />PRINT " MAYOR ES..: " & A <br />IF C > B THEN<br />PRINT " INTERMEDIO ES..: " & C<br />PRINT " MENOR ES..: " & B<br />ELSE <br />PRINT " INTERMEDIO ES..: " & B<br />PRINT " MENOR ES..: " & C<br />ENDIF<br />ELSE <br />IF B > C THEN <br />PRINT " MAYOR ES..: " & B<br /> IF A > C THEN<br />PRINT " INTERMEDIO ES..: " & A<br />PRINT " MENOR ES..: " & C<br />ELSE <br />PRINT " INTERMEDIO ES..: " & C<br />PRINT " MENOR ES..: " & A<br />ENDIF<br />ELSE<br />PRINT " MAYOR ES..: " & C<br />IF A > B THEN<br />PRINT " INTERMEDIO ES..: " & A<br />PRINT " MENOR ES..: " & B<br />ELSE <br />PRINT " INTERMEDIO ES..: " & B<br />PRINT " MENOR ES..: " & A<br />ENDIF<br />ENDIF <br />ENDIF<br />END<br />EJERCICIO 4<br />“DIGITO AUTOVERIFICADOR”<br />125158526670<br />PUBLIC SUB Main()<br />DIM B, C, D, E, F, G, H, I, J, K, W AS Integer <br />DIM A AS String <br />PRINT " INGRESE EL NUMERO DE CEDULA" <br />INPUT A <br />FOR B = 1 TO 9 STEP 1 <br />C = Str(Mid(A, B, 1)) <br />D = B MOD 2 <br />IF D = 0 THEN <br />I = I + C <br />ELSE <br />H = C * 2 <br />IF H > 9 THEN <br />D = H MOD 10 <br />E = Int(h / 10) <br />F = D + E <br />ELSE <br />F = H <br />ENDIF <br />G = G + F <br />ENDIF <br />NEXT <br />J = G + I <br />K = J MOD 10 <br />W = 10 - K <br />PRINT " EL NUMERO VERIFICADOR DE LA CEDULA ES : " <br />PRINT W <br />END<br />EJERCICIO 5<br />“DE TODO UN POCO”<br />PUBLIC SUB Main()<br />DIM a AS Integer<br />DIM NOMBRE, C AS String<br />DIM F, I, X, T AS Integer<br />PRINT " INGRESE UN NÚMERO..:" <br />INPUT a<br />PRINT " INGRESE UN NOMBRE..:" <br />INPUT NOMBRE<br />PRINT " EL NÚMERO QUE INGRESE ES.." , a<br />PRINT " EL NOMBRE ES.." , NOMBRE<br />C = Mid(NOMBRE, 2, 2)<br />PRINT " EL CARACTER SELECCIONADO ES..:" , C<br />F = 1<br />FOR I = 1 TO 5<br /> F = F * I<br />NEXT <br />PRINT " EL FACTORIAL DE 5 ES..: " , F<br /> <br />X = 1<br />WHILE X <= 10<br /> T = 2 * X<br /> PRINT " 2 X " & Str(X) & " =" & Str(T)<br /> X = X + 1<br /> WEND <br />END<br />EJERCICIO 6<br />“EXPORTACION”<br />121348570485<br />'El Ecuador exporta café, cacao y maíz en qq, se desea calcular el total de las exportaciones<br />'y el porcentaje de cada producto exportado, con los siguientes datos<br />'MAIZ 300, CAFE 400, CACAO 800<br />PUBLIC SUB Main()<br />DIM A AS Integer<br />DIM B AS Integer<br />DIM C AS Integer<br />DIM S AS Integer<br />DIM P1 AS Float<br />DIM P2 AS Float<br />DIM P3 AS Float<br />A = 300<br />B = 400<br />C = 800<br />S = A + B + C<br />P1 = A * 100 / S<br />P2 = B * 100 / S<br />P3 = C * 100 / S<br />PRINT " El Total de las exportaciones es..: " & S<br />PRINT " El porcentaje de MAIZ es..: " & P1 & " %" <br />PRINT " El porcentaje de CAFE es..: " & P2 & " %" <br />PRINT " El porcentaje de CACAO es..: " & P3 & " %" <br />END<br />EJERCICIO 7<br />“FUNCIONES”<br />146304038100<br />'PROCEDIMIENTO PRINCIPAL<br />PUBLIC SUB Main()<br /> DIM a, b, h, z AS Integer<br /> PRINT " Ingrese un número.:" <br /> INPUT a<br /> PRINT " Ingrese un número.:" <br /> INPUT b<br /> pintamedia(a, b)<br /> h = 30<br /> z = 70<br /> pintamedia(h, z) <br />END<br />'PROCEDIMIENTO 1<br />PUBLIC SUB pintamedia(v1 AS Integer, v2 AS Integer) AS Integer<br /> DIM s AS Integer<br /> s = v1 + v2<br /> PRINT " La suma es..: " , s<br />END<br />EJERCICIO 8<br />“PINTAMEDIA”<br />135636020320<br />PUBLIC SUB Main()<br /> DIM a, b AS Integer<br /> PRINT " Ingrese un número.:" <br /> INPUT a<br /> PRINT " Ingrese un número.:" <br /> INPUT b<br /> 'Llamada a función suma, resta, multiplicacion y division<br /> PRINT " La suma es..: " , suma(a, b)<br /> PRINT " La resta es..: " , resta(a, b)<br /> PRINT " La multiplicación es..: " , multiplicacion(a, b)<br /> PRINT " La división es..: " , division(a, b)<br />END<br />'Función suma<br />PUBLIC SUB suma(v1 AS Integer, v2 AS Integer) AS Integer<br /> DIM s AS Integer<br /> s = v1 + v2<br /> RETURN s<br />END<br />'Función resta<br />PUBLIC SUB resta(v1 AS Integer, v2 AS Integer) AS Integer<br /> DIM r AS Integer<br /> r = v1 - v2<br /> RETURN r<br />END<br />'Función multiplicación<br />PUBLIC SUB multiplicacion(v1 AS Integer, v2 AS Integer) AS Integer<br /> DIM m AS Integer<br /> m = v1 * v2<br /> RETURN m<br />END<br />'Función división<br />PUBLIC SUB division(v1 AS Integer, v2 AS Integer) AS Integer<br /> DIM d AS Integer<br /> d = v1 / v2<br /> RETURN d<br />END<br />EJERCICIO 9<br />“MODULO FIBONACCI”<br />110934549530<br />PUBLIC SUB Main()<br /> 'Serie de Fibonacci<br /> DIM p, s, x, t AS Integer<br /> DIM fibo AS String<br /> p = 0<br /> s = 1<br /> fibo = Str(p) & " " & Str(s)<br /> WHILE x < 5<br /> t = p + s<br /> fibo = fibo & " " & Str(t) <br /> p = s<br /> s = t<br /> x = x + 1<br /> WEND <br /> PRINT fibo<br />END<br />EJERCICIO 10<br />“OBJETO SUPERHEROE”<br />83248520955<br />PRIVATE Heroe1 AS NEW SUPERHEROE<br />PRIVATE Heroe2 AS NEW SUPERHEROE<br />PUBLIC SUB Main()<br />Heroe1.Nombre = " Superman" <br />Heroe1.Actor = " Ramón Zambrano" <br />Heroe1.Habilidad = " Volar" <br />Heroe1.Imprime()<br />WITH Heroe2 <br /> .Nombre = " Batman" <br /> .Actor = " Ochoa" <br /> .Habilidad = " Visión Nocturna" <br /> .Imprime<br />END WITH<br />END<br />EJERCICIO 11<br />“OBJETO SERES VIVOS”<br />105981568580<br />INHERITS SeresVivos<br />PRIVATE Nombre AS String<br />PRIVATE Apellido AS String<br />PUBLIC SUB PoneNombre(cadena AS String)<br /> Nombre = cadena<br />END <br />PUBLIC SUB PoneApellido(cadena AS String)<br /> Apellido = cadena<br />END <br />PUBLIC FUNCTION Nombrecompleto() AS String<br /> RETURN Nombre & " " & Apellido<br />END<br />EJERCICIO 12<br />“OBJETO VEHICULO”<br />119697555245<br />PRIVATE marca AS String<br />PRIVATE modelo AS Integer<br />PRIVATE precio AS Integer<br />PRIVATE color AS String<br />PRIVATE placa AS String<br />PUBLIC SUB mar(marca1 AS String)<br /> marca = marca1<br />END <br />PUBLIC SUB model(fecha AS String)<br /> modelo = fecha<br />END <br />PUBLIC SUB pre(valor AS Integer)<br /> precio = valor<br />END <br />PUBLIC SUB col(tinte AS String)<br /> color = tinte<br />END <br />PUBLIC SUB pla(codigo AS String)<br /> placa = codigo<br />END <br />PUBLIC FUNCTION marcaauto() AS String<br /> RETURN marca<br />END <br />PUBLIC FUNCTION modeloauto() AS String<br /> RETURN modelo<br />END<br />PUBLIC FUNCTION precioauto() AS Integer<br /> RETURN precio<br />END<br />PUBLIC FUNCTION colorauto() AS String<br /> RETURN color<br />END<br />PUBLIC FUNCTION placaauto() AS String<br /> RETURN placa<br />END<br />EJERCICIOS “GAMBAS”<br />(APLICACIÓN GRAFICA)<br />EJERCICIO 13<br />“OPERACIONES BÁSICAS”<br />155638548895<br />PUBLIC SUB Button1_Click()<br /> suma.text = Val(num1.text) + Val(num2.text) <br />resta.text = num1.text - num2.text<br />multi.text = num1.text * num2.text<br />divi.text = num1.text / num2.text<br />END<br />PUBLIC SUB Button2_Click()<br /> num1.text = " " <br /> num2.text = " " <br /> suma.text = " " <br /> resta.text = " " <br /> multi.text = " " <br /> divi.text = " " <br />END<br />PUBLIC SUB Button3_Click()<br /> ME.Close<br />END<br />EJERCICIO 14<br />“VENTANA”<br />208978550165<br />PUBLIC SUB Main()<br />DIM vent AS window<br />vent = NEW window<br />vent.show()<br />END<br />EJERCICIO 15<br />“MENU”<br />152463527305<br />PUBLIC SUB Timer1_Timer()<br /> segundos.text = Val(segundos.Text) + 1<br /> IF segundos.text = 59 THEN <br /> minutos.text = Val(minutos.text) + 1<br /> segundos.text = " 0" <br /> segundos.text = Val(segundos.text) + 1 <br /> ELSE <br /> IF minutos.text = 59 THEN <br /> horas.text = Val(horas.text) + 1<br /> minutos.text = " 0" <br /> ENDIF <br /> ENDIF <br />END<br />PUBLIC SUB Button1_Click()<br /> IF Button1.text = " Iniciar" THEN <br /> Timer1.enabled = TRUE<br /> Button1.caption = " Parar" <br /> ELSE <br /> Timer1.Enabled = FALSE<br /> Button1.text = " Iniciar" <br /> ENDIF <br />END<br />PUBLIC SUB Button2_Click()<br /> segundos.text = " 0" <br /> minutos.text = " 0" <br /> horas.text = " 0" <br />END<br />EJERCICIO 16<br />308419533655013335336550“JUEGO”<br />PUBLIC SUB Button1_Click()<br /> DIM n1, n2, n3 AS Integer<br /> RANDOMIZE <br /> n1 = Int(Rnd() * 10)<br /> n2 = Int(Rnd() * 10)<br /> n3 = Int(Rnd() * 10)<br /> TextBox1.Text = n1<br /> TextBox2.Text = n2<br /> TextBox3.Text = n3<br /> IF n1 = n2 AND n1 = n3 THEN<br /> Message(" GANASTES" )<br /> TextBox5.Text = TextBox4.Text * 2 <br /> ELSE <br /> IF n1 = 7 AND n2 = 7 AND n3 = 7 THEN <br /> Message(" CONGRATULATIONS GANASTES EL PREMIO MAYOR" )<br /> TextBox5.Text = TextBox4.Text * 4<br /> ENDIF <br /> ENDIF <br />END<br />PUBLIC SUB Button2_Click()<br /> ME.Close<br />END<br />EJERCICIO 17<br />“GRÁFICOS”<br />149542538100<br />PUBLIC r AS Integer<br />PUBLIC posy AS Integer<br />PUBLIC posx AS Integer<br />PUBLIC al AS Integer<br />PUBLIC ba AS Integer<br />PUBLIC SUB Form_Open()<br />r = 20<br />END<br />PUBLIC SUB Button1_Click()<br /> posy = area1.Height / 2<br /> posx = area1.Width / 2<br /> Draw.Begin(area1)<br /> Draw.FillColor = Color.RGB(128, 255, 0)<br /> Draw.FillStyle = Fill.Solid<br /> Draw.Circle(posx, posy, r)<br /> r = r + 20<br /> 'Draw.Ellipse(200, 200, 100, 50)<br /> Draw.End<br />END<br />PUBLIC SUB Button3_Click()<br /> ME.Close<br />END<br />PUBLIC SUB Button2_Click()<br /> area1.Clear<br /> posy = area1.Height / 2<br /> posx = area1.Width / 2<br /> Draw.Begin(area1)<br /> Draw.FillColor = Color.RGB(128, 255, 0)<br /> Draw.FillStyle = Fill.Solid<br /> Draw.Circle(posx, posy, r)<br /> r = r - 20<br /> 'Draw.Ellipse(200, 200, 100, 50)<br /> Draw.End<br />END<br />PUBLIC SUB Button4_Click()<br /> area1.Clear<br /> Draw.Begin(area1)<br /> posy = area1.Height / 2<br /> posx = area1.Width / 2<br /> Draw.FillColor = Color.RGB(255, 223, 117)<br /> Draw.FillStyle = Fill.Solid<br /> <br /> Draw.Rect(posx, posy, al, ba)<br /> Draw.End<br /> al = al + 10<br /> ba = ba + 10<br />END<br />EJERCICIO 18<br />“PROTECTOR DE PANTALLA”<br />156591053340<br />PUBLIC C1 AS Integer<br />PUBLIC C2 AS Integer<br />PUBLIC C AS Integer<br />PUBLIC r AS Integer<br />PUBLIC SUB Button1_Click()<br /> IF Button1.Text = " Iniciar Fondo" THEN <br /> Timer1.Enabled = TRUE<br /> Button1.Caption = " Parar" <br /> ELSE <br /> Timer1.Enabled = FALSE<br /> Button1.Text = " Iniciar Fondo" <br /> ENDIF <br />END<br />PUBLIC SUB Button2_Click()<br /> ME.Close<br />END<br />PUBLIC SUB Timer1_Timer()<br /> C1 = Int(Rnd() * 700)<br /> C2 = Int(Rnd() * 700)<br /> C = Int(Rnd() * 15)<br /> Draw.Begin(area1)<br /> Draw.FillColor = Color.RGB((160 + c1), (2 + c2), (c1 + C2)) <br />' coge los colores que se designen<br /> Draw.FillStyle = Fill.Solid<br /> Draw.Circle(C1, C2, C) <br /> Draw.End<br />END<br />EJERCICIO 19<br />“CALCULADORA”<br />121348545720<br />PUBLIC BAN AS Integer<br />PUBLIC OP1 AS Float<br />PUBLIC OP2 AS Float<br />PUBLIC SUB Button10_Click()<br /> visor.text = visor.Text & " 0" <br />END<br />PUBLIC SUB Button11_Click()<br /> visor.text = visor.Text & " ." <br />END<br />PUBLIC SUB Button7_Click()<br /> visor.text = visor.Text & " 1" <br />END<br />PUBLIC SUB Button8_Click()<br /> visor.text = visor.Text & " 2" <br />END<br />PUBLIC SUB Button9_Click()<br /> visor.text = visor.Text & " 3" <br />END<br />PUBLIC SUB Button4_Click()<br /> visor.text = visor.Text & " 4" <br />END<br />PUBLIC SUB Button5_Click()<br /> visor.text = visor.Text & " 5" <br />END<br />PUBLIC SUB Button6_Click()<br /> visor.text = visor.Text & " 6" <br />END<br />PUBLIC SUB Button1_Click()<br /> visor.text = visor.Text & " 7" <br />END<br />PUBLIC SUB Button2_Click()<br /> visor.text = visor.Text & " 8" <br />END<br />PUBLIC SUB Button3_Click()<br /> visor.text = visor.Text & " 9" <br />END<br />PUBLIC SUB Button12_Click()<br /> ME.Close<br />END<br />PUBLIC SUB Button16_Click()<br /> visor.text = " " <br />END<br />PUBLIC FUNCTION operacion(v1 AS Float, v2 AS Float, opera AS Integer) AS Float<br />DIM re AS Float<br /> SELECT CASE opera<br /> CASE 1<br /> re = v1 + v2<br /> CASE 2<br /> re = v1 - v2<br /> CASE 3<br /> re = v1 * v2<br /> CASE 4<br /> re = v1 / v2<br /> CASE 5<br /> re = (v1 * v2) / 100<br /> CASE 6<br /> re = v1 ^ 2<br /> CASE 7<br /> re = v1 ^ 3<br /> CASE 8<br /> re = v1 ^ v2<br /> CASE 9<br /> re = 1 / v1<br /> END SELECT <br /> <br /> RETURN re<br />END<br />PUBLIC SUB Button13_Click()<br /> BAN = 1<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.Clear<br />END<br />PUBLIC SUB Button14_Click()<br /> BAN = 2<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.Clear<br />END<br />PUBLIC SUB Button18_Click()<br /> BAN = 3<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.Clear<br />END<br />PUBLIC SUB Button17_Click()<br /> BAN = 4<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.Clear<br />END<br />PUBLIC SUB Button15_Click()<br /> IF visor.text <> 0 THEN <br /> OP2 = visor.Text<br /> ELSE <br /> OP2 = 0<br /> ENDIF <br /> <br /> visor.Text = operacion(OP1, OP2, BAN)<br />END<br />PUBLIC SUB Button19_Click()<br /> BAN = 5<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.Clear<br />END<br />PUBLIC SUB Button20_Click()<br /> BAN = 6<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.text = OP1 <br />END<br />PUBLIC SUB Button21_Click()<br /> DIM valor, x1, x2, i AS Integer<br /> DIM cadena, cadena2 AS String<br /> valor = visor.Text<br /> WHILE valor > 0<br /> x1 = valor MOD 2<br /> x2 = Int(valor / 2)<br /> cadena = cadena & Str(x1)<br /> valor = x2<br /> WEND <br /> <br /> FOR i = Len(cadena) TO 1 STEP -1<br /> cadena2 = cadena2 & (Mid(cadena, i, 1))<br /> NEXT <br /> visor.text = cadena2<br />END<br />PUBLIC SUB Button22_Click()<br /> DIM valor, x1, x2, i AS Integer<br /> DIM cadena, cadena2 AS String<br /> valor = visor.Text<br /> WHILE valor > 0<br /> x1 = valor MOD 8<br /> x2 = Int(valor / 8)<br /> cadena = cadena & Str(x1)<br /> valor = x2<br /> WEND <br /> <br /> FOR i = Len(cadena) TO 1 STEP -1<br /> cadena2 = cadena2 & (Mid(cadena, i, 1))<br /> NEXT <br /> visor.text = cadena2<br />END<br />PUBLIC SUB Button23_Click()<br /> DIM valor, x1, x2, i AS Integer<br /> DIM cadena, cadena2 AS String<br /> valor = visor.Text<br /> <br /> WHILE valor > 0<br /> x1 = valor MOD 16<br /> x2 = Int(valor / 16)<br /> IF x1 = 10 THEN<br /> cadena = cadena & " A" <br /> ELSE <br /> IF x1 = 11 THEN<br /> cadena = cadena & " B" <br /> ELSE<br /> IF x1 = 12 THEN<br /> cadena = cadena & " C" <br /> ELSE<br /> IF x1 = 13 THEN<br /> cadena = cadena & " D" <br /> ELSE<br /> IF x1 = 14 THEN<br /> cadena = cadena & " E" <br /> ELSE<br /> IF x1 = 15 THEN<br /> cadena = cadena & " F" <br /> ELSE<br /> cadena = cadena & Str(x1)<br /> ENDIF<br /> ENDIF<br /> ENDIF<br /> ENDIF<br /> ENDIF<br /> ENDIF <br /> valor = x2<br /> WEND <br /> <br /> FOR i = Len(cadena) TO 1 STEP -1<br /> cadena2 = cadena2 & (Mid(cadena, i, 1))<br /> NEXT <br /> visor.Text = cadena2 <br />END<br />PUBLIC SUB Button24_Click()<br /> BAN = 7<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.text = OP1 <br />END<br />PUBLIC SUB Button27_Click()<br /> BAN = 8<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.Clear <br />END<br />PUBLIC SUB Button25_Click()<br /> BAN = 9<br /> IF visor.text <> 0 THEN <br /> OP1 = visor.Text<br /> ELSE <br /> OP1 = 0<br /> ENDIF <br /> visor.text = OP1<br />END<br />PUBLIC SUB Button26_Click()<br /> DIM a, b AS Long<br /> DIM valor AS Integer<br /> valor = visor.Text<br /> b = 1<br /> FOR a = valor TO 1 STEP -1<br /> b = b * a<br /> NEXT <br /> visor.Text = b<br />END<br />PUBLIC SUB Button28_Click()<br /> DIM r AS Float<br /> r = Rad(visor.text)<br /> visor.text = Sin(r)<br />END<br />PUBLIC SUB Button29_Click()<br /> DIM r AS Float<br /> r = Rad(visor.text)<br /> visor.text = Cos(r)<br />END<br />PUBLIC SUB Button30_Click()<br /> DIM r AS Float<br /> r = Rad(visor.text)<br /> visor.text = Tan(r)<br />END<br />EJERCICIO 20<br />“CONVIERTE NÚMERO A LETRAS”<br />76771548260<br />PUBLIC FUNCTION EnLetras(numero AS String) AS String <br /> DIM b, paso AS Integer <br /> DIM expresion, entero, deci, flag AS String <br /> flag = " N" <br /> FOR paso = 1 TO Len(numero) <br /> IF Mid(numero, paso, 1) = " ." THEN <br /> flag = " S" <br /> ELSE <br /> IF flag = " N" THEN <br /> entero = entero & Mid(numero, paso, 1) <br /> ELSE <br /> deci = deci & Mid(numero, paso, 1) <br /> END IF <br /> END IF <br /> NEXT <br /> IF Len(deci) = 1 THEN <br /> deci = deci & " 0" <br /> END IF <br /> flag = " N" <br /> IF Val(numero) >= -999999999 AND Val(numero) <= 999999999 THEN<br /> FOR paso = Len(entero) TO 1 STEP -1 <br /> b = Len(entero) - (paso - 1) <br /> <br /> SELECT CASE paso <br /> CASE 3, 6, 9 <br /> SELECT CASE Mid(entero, b, 1) <br /> CASE " 1" <br /> IF Mid(entero, b + 1, 1) = " 0" AND Mid(entero, b + 2, 1) = " 0" THEN <br /> expresion = expresion & " cien " <br /> ELSE <br /> expresion = expresion & " ciento " <br /> END IF <br /> CASE " 2" <br /> expresion = expresion & " doscientos " <br /> CASE " 3" <br /> expresion = expresion & " trescientos " <br /> CASE " 4" <br /> expresion = expresion & " cuatrocientos " <br /> CASE " 5" <br /> expresion = expresion & " quinientos " <br /> CASE " 6" <br /> expresion = expresion & " seiscientos " <br /> CASE " 7" <br /> expresion = expresion & " setecientos " <br /> CASE " 8" <br /> expresion = expresion & " ochocientos " <br /> CASE " 9" <br /> expresion = expresion & " novecientos " <br /> END SELECT <br /> <br /> CASE 2, 5, 8 <br /> SELECT CASE Mid(entero, b, 1) <br /> CASE " 1" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> flag = " S" <br /> expresion = expresion & " diez " <br /> END IF <br /> IF Mid(entero, b + 1, 1) = " 1" THEN <br /> flag = " S" <br /> expresion = expresion & " once " <br /> END IF <br /> IF Mid(entero, b + 1, 1) = " 2" THEN <br /> flag = " S" <br /> expresion = expresion & " doce " <br /> END IF <br /> IF Mid(entero, b + 1, 1) = " 3" THEN <br /> flag = " S" <br /> expresion = expresion & " trece " <br /> END IF <br /> IF Mid(entero, b + 1, 1) = " 4" THEN <br /> flag = " S" <br /> expresion = expresion & " catorce " <br /> END IF <br /> IF Mid(entero, b + 1, 1) = " 5" THEN <br /> flag = " S" <br /> expresion = expresion & " quince " <br /> END IF <br /> IF Mid(entero, b + 1, 1) > " 5" THEN <br /> flag = " N" <br /> expresion = expresion & " dieci" <br /> END IF<br /> <br /> CASE " 2" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " veinte " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " veinti" <br /> flag = " N" <br /> END IF <br /> <br /> CASE " 3" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " treinta " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " treinta y " <br /> flag = " N" <br /> END IF <br /> <br /> CASE " 4" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " cuarenta " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " cuarenta y " <br /> flag = " N" <br /> END IF <br /> <br /> CASE " 5" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " cincuenta " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " cincuenta y " <br /> flag = " N" <br /> END IF <br /> <br /> CASE " 6" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " sesenta " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " sesenta y " <br /> flag = " N" <br /> END IF <br /> <br /> CASE " 7" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " setenta " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " setenta y " <br /> flag = " N" <br /> END IF <br /> <br /> CASE " 8" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " ochenta " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " ochenta y " <br /> flag = " N" <br /> END IF <br /> <br /> CASE " 9" <br /> IF Mid(entero, b + 1, 1) = " 0" THEN <br /> expresion = expresion & " noventa " <br /> flag = " S" <br /> ELSE <br /> expresion = expresion & " noventa y " <br /> flag = " N" <br /> END IF <br /> END SELECT <br /> <br /> CASE 1, 4, 7 <br /> SELECT CASE Mid(entero, b, 1) <br /> CASE " 1" <br /> IF flag = " N" THEN <br /> IF paso = 1 THEN <br /> expresion = expresion & " uno " <br /> ELSE <br /> expresion = expresion & " un " <br /> END IF <br /> END IF <br /> CASE " 2" <br /> IF flag = " N" THEN <br /> expresion = expresion & " dos " <br /> END IF <br /> CASE " 3" <br /> IF flag = " N" THEN <br /> expresion = expresion & " tres " <br /> END IF <br /> CASE " 4" <br /> IF flag = " N" THEN <br /> expresion = expresion & " cuatro " <br /> END IF <br /> CASE " 5" <br /> IF flag = " N" THEN <br /> expresion = expresion & " cinco " <br /> END IF <br /> CASE " 6" <br /> IF flag = " N" THEN <br /> expresion = expresion & " seis " <br /> END IF <br /> CASE " 7" <br /> IF flag = " N" THEN <br /> expresion = expresion & " siete " <br /> END IF <br /> CASE " 8" <br /> IF flag = " N" THEN <br /> expresion = expresion & " ocho " <br /> END IF <br /> CASE " 9" <br /> IF flag = " N" THEN <br /> expresion = expresion & " nueve " <br /> END IF <br /> END SELECT <br /> END SELECT <br /> IF paso = 4 THEN <br /> IF Mid(entero, 6, 1) <> " 0" OR Mid(entero, 5, 1) <> " 0" OR Mid(entero, 4, 1) <> " 0" OR (Mid(entero, 6, 1) = " 0" AND Mid(entero, 5, 1) = " 0" AND Mid(entero, 4, 1) = " 0" AND Len(entero) <= 6) THEN <br /> expresion = expresion & " mil " <br /> END IF <br /> END IF <br /> IF paso = 7 THEN <br /> IF Len(entero) = 7 AND Mid(entero, 1, 1) = " 1" THEN <br /> expresion = expresion & " millón " <br /> ELSE <br /> expresion = expresion & " millones " <br /> END IF <br /> END IF <br /> NEXT <br /> IF deci <> " " THEN <br /> IF Mid(entero, 1, 1) = " -" THEN <br /> expresion = " menos " & expresion & " con " & deci & " /100" <br /> ELSE <br /> expresion = expresion & " con " & deci & " /100" <br /> END IF <br /> ELSE <br /> IF Mid(entero, 1, 1) = " -" THEN <br /> expresion = " menos " & expresion <br /> ELSE <br /> expresion = expresion <br /> END IF <br /> END IF <br /> ELSE <br /> expresion = " " <br /> END IF <br /> TextBox2.Text = expresion<br />END FUNCTION <br />PUBLIC SUB Button1_Click()<br />EnLetras(TextBox1.text) <br />END<br />PUBLIC SUB Button2_Click()<br /> ME.Close<br />END<br />PUBLIC SUB Button3_Click()<br /> TextBox1.Text = " " <br /> TextBox2.Text = " " <br />END<br />EJERCICIO 21<br />“FACTURA”<br />126111049530<br />PUBLIC r AS Integer<br />PUBLIC i AS Integer<br />PUBLIC m AS Integer<br />PUBLIC SUB Form_Open()<br />TextBox6.SetFocus<br />'Número de columnas<br />cuadro.Columns.Count = 5<br />'Número de filas<br />cuadro.Rows.Count = 10<br />cuadro.Columns[0].width = 50<br />cuadro.Columns[1].width = 200<br />cuadro.Columns[2].width = 80<br />cuadro.Columns[3].width = 50<br />cuadro.Columns[4].width = 80<br />cuadro[0, 0].text = " NUM" <br />cuadro[0, 1].text = " DETALLE" <br />cuadro[0, 2].text = " PRECIO.U" <br />cuadro[0, 3].text = " CANT" <br />cuadro[0, 4].text = " TOTAL A PAGAR" <br />r = 0<br />i = 0<br />END<br />PUBLIC SUB TextBox3_KeyPress()<br /> IF Key.code = 65293 THEN <br /> IF TextBox3.text = " " THEN <br /> Message.Info(" Ingrese Valor" )<br /> TextBox3.SetFocus<br /> ELSE <br /> i = i + 1<br /> r = r + 1<br /> TextBox4.text = i<br /> cuadro[r, 0].text = Val(TextBox4.text)<br /> cuadro[r, 1].text = (TextBox1.text)<br /> cuadro[r, 2].text = TextBox2.text<br /> cuadro[r, 3].text = TextBox3.text<br /> 'PRECIO TOTAL<br /> TextBox5.Text = (TextBox2.text) * (TextBox3.text)<br /> cuadro[r, 4].text = Val(TextBox5.text)<br /> m = m + TextBox5.Text<br /> TextBox1.text = " " <br /> TextBox2.text = " " <br /> TextBox3.text = " " <br /> TextBox1.SetFocus<br /> ENDIF <br /> ENDIF <br />END<br />PUBLIC SUB Button2_Click()<br /> TextBox6.Text = m<br /> TextBox7.Text = (m * 7) / 100<br /> TextBox8.Text = (((TextBox6.Text) - (TextBox7.Text) * 12) / 100)<br /> TextBox9.Text = (TextBox6.Text) - (TextBox7.Text) + (TextBox8.Text)<br />END<br />PUBLIC SUB TextBox2_KeyPress()<br /> IF Key.code = 65293 THEN <br /> IF TextBox2.text = " " THEN <br /> Message.Info(" Ingrese Precio Unitario" )<br /> TextBox2.SetFocus<br /> ELSE <br /> TextBox3.Text.SetFocus<br /> ENDIF <br /> ENDIF <br />END<br />PUBLIC SUB TextBox1_KeyPress()<br /> IF Key.code = 65293 THEN <br /> IF TextBox1.text = " " THEN <br /> Message.Info(" Ingrese Detalle" )<br /> TextBox1.SetFocus<br /> ELSE <br /> TextBox2.Text.SetFocus<br /> ENDIF <br /> ENDIF <br />END<br />PUBLIC SUB Button1_Click()<br /> TextBox4.text = " " <br /> TextBox5.text = " " <br /> TextBox6.text = " " <br /> TextBox7.text = " " <br /> TextBox8.text = " " <br /> TextBox9.text = " " <br />END<br />PUBLIC SUB Button3_Click()<br /> ME.Close<br />END<br />

×