38

Ejemplo En Gamabas

  • Upload
    eduann

  • View
    1.089

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Ejemplo En Gamabas
Page 2: Ejemplo En Gamabas

FACTURA

CODIGO FUENTE

PUBLIC I AS IntegerPUBLIC m AS Integer PUBLIC R AS Integer PUBLIC SUB _new()END

PUBLIC SUB Form_Open()TextBox1.SetFocusGridView1.Columns.Count = 5GridView1.Rows.Count = 10GridView1.Columns[0].Width = 50GridView1.Columns[1].Width = 200GridView1.Columns[2].Width = 80GridView1.Columns[3].Width = 80GridView1.Columns[4].Width = 80GridView1[0, 0].Text = "NUM"GridView1[0, 1].Text = "DETALLE"GridView1[0, 2].Text = "PRECIO U/"GridView1[0, 3].Text = "CANT"GridView1[0, 4].Text = "TOTAL"R = 0I = 0' GridView1[0, 3].Text =

Page 3: Ejemplo En Gamabas

END

PUBLIC SUB TextBox3_KeyPress() IF Key.Code = 65293 THEN IF TextBox3.Text = "" THEN Message("INGRESE UN VALOR") TextBox3.SetFocusELSE I = I + 1R = R + 1TextBox1.Text = IGridView1[r, 0].Text = Val(TextBox8.Text)GridView1[r, 1].Text = (TextBox1.Text)GridView1[r, 2].Text = TextBox2.TextGridView1[r, 3].Text = TextBox3.Text'precioTextBox9.Text = Val(TextBox2.Text) * (TextBox3.Text)GridView1[r, 4].Text = Val(TextBox9.Text)m = m + Val(TextBox9.Text)TextBox1.text = ""TextBox2.text = ""TextBox3.text = ""TextBox1.SetFocusENDIFENDIF END

PUBLIC SUB Button2_Click() TextBox4.Text = m TextBox5.Text = (m * 7) / 100 TextBox6.Text = ((((textBox4.Text) - (TextBox5.text)) * 12) / 100) TextBox7.Text = (textBox4.Text) - (TextBox5.Text) + (TextBox6.Text)END

PUBLIC SUB Button1_Click()TextBox1.text = ""TextBox2.text = ""TextBox3.text = ""TextBox1.SetFocusGridView1.ClearEND

PUBLIC SUB TextBox2_KeyPress() IF Key.Code = 65293 THEN IF TextBox2.Text = "" THEN

Page 4: Ejemplo En Gamabas

Message("INGRESE UN VALOR") TextBox2.SetFocus ELSE TextBox3.SetFocus ENDIF ENDIF END

PUBLIC SUB TextBox1_KeyPress() IF Key.Code = 65293 THEN IF TextBox2.Text = "" THEN Message("INGRESE UN VALOR") TextBox2.SetFocus ELSE TextBox3.SetFocus ENDIF ENDIF END

Page 5: Ejemplo En Gamabas

2.- CALCULADORA

' Gambas class filePUBLIC BAN AS IntegerPUBLIC OP1 AS FloatPUBLIC OP2 AS Float

PUBLIC SUB Button1_Click()TextBox1.Text = TextBox1.Text & "1" END

PUBLIC SUB Button2_Click(TextBox1.Text = TextBox1.Text & "2" END

PUBLIC SUB Button3_Click() TextBox1.Text = TextBox1.Text & "3"END

PUBLIC SUB Button6_Click() TextBox1.Text = TextBox1.Text & "4"END

PUBLIC SUB Button7_Click() TextBox1.Text = TextBox1.Text & "5"END

Page 6: Ejemplo En Gamabas

PUBLIC SUB Button8_Click() TextBox1.Text = TextBox1.Text & "6"END

PUBLIC SUB Button11_Click() TextBox1.Text = TextBox1.Text & "7"END

PUBLIC SUB Button9_Click() TextBox1.Text = TextBox1.Text & "8"END

PUBLIC SUB Button10_Click() TextBox1.Text = TextBox1.Text & "9"

END

PUBLIC SUB Button4_Click() TextBox1.Text = TextBox1.Text & "0"END

PUBLIC SUB Button5_Click() TextBox1.Text = TextBox1.Text & "00"END

PUBLIC SUB Button18_Click() FMain.CLOSE END

PUBLIC SUB Button17_Click() TextBox1.Text = TextBox1.Text & "."END

PUBLIC SUB Button16_Click() BAN = 1 IF TextBox1.Text <> 0 THEN OP1 = TextBox1.Text ELSE OP1 = 0 ENDIF TextBox1.ClearEND

Page 7: Ejemplo En Gamabas

PUBLIC SUB Button19_Click() TextBox1.Text = ""END

PUBLIC SUB Button15_Click() BAN = 2 IF TextBox1.Text <> 0 THEN OP1 = TextBox1.Text ELSE OP1 = 0 ENDIF TextBox1.ClearEND

PUBLIC SUB Button13_Click() BAN = 3 IF TextBox1.Text <> 0 THEN OP1 = TextBox1.Text ELSE OP1 = 0 ENDIF TextBox1.ClearEND

PUBLIC SUB Button12_Click() BAN = 4 IF TextBox1.Text <> 0 THEN OP1 = TextBox1.Text ELSE OP1 = 0 ENDIF TextBox1.ClearEND

PUBLIC SUB Button14_Click() IF TextBox1.Text <> 0 THEN OP2 = TextBox1.Text ELSE OP2 = 0 ENDIF TextBox1.Text = OPERACION(OP1, OP2, BAN)END

PUBLIC FUNCTION OPERACION(V1 AS Float, V2 AS Float, OPER AS Float) AS Float

Page 8: Ejemplo En Gamabas

DIM RE AS Float DIM X, Y, Z, X1, Y1, Z1, X2, Y2, Z2 AS Integer DIM valor, i AS Integer DIM cadena, cadena2 AS String DIM XX, MEA AS String SELECT CASE OPER CASE 1 RE = V1 + V2 Z2 = 1 CASE 2 RE = V1 - V2 Z2 = 1 CASE 3 RE = V1 * V2 Z2 = 1 CASE 4 RE = V1 / V2 Z2 = 1 CASE 5 RE = (V1 * V2) / 100 Z2 = 1 CASE 6 RE = V1 ^ V2 Z2 = 1 CASE 7 RE = V1 ^ 2 Z2 = 1 CASE 8 RE = V1 ^ 3 Z2 = 1 CASE 9 RE = 1 / V1 Z2 = 1 END SELECT IF Z2 = 1 RETURN REELSE RETURN Y1 ENDIF ENDPUBLIC SUB Button20_Click() BAN = 5 IF TextBox1.Text <> 0 THEN OP1 = TextBox1.Text

Page 9: Ejemplo En Gamabas

ELSE OP1 = 0 ENDIF TextBox1.ClearEND

PUBLIC SUB Button21_Click() BAN = 6 IF TextBox1.Text <> 0 THEN OP1 = TextBox1.Text ELSE OP1 = 0 ENDIF TextBox1.ClearEND

PUBLIC SUB Button22_Click()

BAN = 7 IF TextBox1.Text <> 0 THEN OP1 = TextBox1.Text ELSE OP1 = 0 ENDIF TextBox1.Text = OP1END

PUBLIC SUB Button23_Click()DIM valor, x1, x2, i AS IntegerDIM cadena, cadena2 AS String valor = TextBox1.Text WHILE valor > 0 x1 = valor MOD 2 x2 = Int(valor / 2) cadena = cadena & Str(x1) valor = x2 WEND FOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & (Mid(cadena, i, 1)) NEXT TextBox1.Text = cadena2 END

PUBLIC SUB Button25_Click()

Page 10: Ejemplo En Gamabas

'Calculo a octal de un número decimalDIM valor, x1, x2, i AS IntegerDIM cadena, cadena2 AS String valor = TextBox1.Text WHILE valor > 0 x1 = valor MOD 16 x2 = Int(valor / 16) IF x1 = 10 THEN cadena = cadena & "A" ELSE IF x1 = 11 THEN cadena = cadena & "B" ELSE IF x1 = 12 THEN cadena = cadena & "C" ELSE IF x1 = 13 THEN cadena = cadena & "D" ELSE IF x1 = 14 THEN cadena = cadena & "E" ELSE IF x1 = 15 THEN cadena = cadena & "F" ELSE cadena = cadena & Str(x1) ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF valor = x2 WEND FOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & (Mid(cadena, i, 1)) NEXT TextBox1.Text = cadena2 END

PUBLIC SUB Button24_Click() 'Calculo a octal de un número decimalDIM valor, x1, x2, i AS IntegerDIM cadena, cadena2 AS String

Page 11: Ejemplo En Gamabas

valor = TextBox1.Text WHILE valor > 0 x1 = valor MOD 8 x2 = Int(valor / 8) cadena = cadena & Str(x1) valor = x2 WEND FOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & (Mid(cadena, i, 1)) NEXT TextBox1.Text = cadena2 END

PUBLIC SUB Button29_Click()TextBox1.Text = TextBox1.Text ^ 3END

PUBLIC SUB Button27_Click()TextBox1.Text = 1 / TextBox1.TextEND

PUBLIC SUB Button26_Click()' DIM N AS FloatIF TextBox1.Text = "" THEN Message("INGRESE DATO")' ELSE' IF RadioButton1.Value = TRUE THEN ' N = Str(Sin(Val(TextBox1.Text)))' TextBox1.Text = N' RadioButton2.Value = FALSEELSE ' IF RadioButton2.Value = TRUE THEN TextBox1.Text = Sin(Pi * (Val(TextBox1.Text)) / 180)' ENDIF ' ENDIF ENDIF END

PUBLIC SUB Button31_Click()' DIM N AS Float' N = Cos(TextBox1.Text)' TextBox1.Text = NIF TextBox1.Text = "" THEN Message("INGRESE DATO")

Page 12: Ejemplo En Gamabas

ELSETextBox1.Text = Cos(Pi * (Val(TextBox1.Text)) / 180)ENDIF END

PUBLIC SUB Button30_Click() IF TextBox1.Text = "" THEN Message("INGRESE DATO")ELSETextBox1.Text = Tan(Pi * (Val(TextBox1.Text)) / 180)ENDIF END

PUBLIC SUB Button28_Click() DIM FAC, N AS Float N = TextBox1.Text FAC = 1 WHILE (N <> 0) FAC = FAC * N N = N - 1 TextBox1.Text = FAC WEND END

Page 13: Ejemplo En Gamabas

3.- PORCENTAJE DE UN PRODUCTO

PUBLIC SUB Main()DIM A AS IntegerDIM B AS IntegerDIM C AS IntegerDIM T AS IntegerDIM PM AS FloatDIM PC AS FloatDIM PO AS FloatA = 300B = 400C = 800T = A + B + CPM = (300 * 100) / TPC = (400 * 100) / TPO = (800 * 100) / TPRINT "EL TOTAL ES...."PRINT TPRINT "EL PORCENTAJE DE MAIZ ES...."PRINT PM & "%"PRINT "EL PORCENTAJE DE CAFE ES...."PRINT PC & "%"PRINT "EL PORCENTAJE DE CACAO ES...."PRINT PO & "%"END

Page 14: Ejemplo En Gamabas

4.- REALIZAR UN CÍRCULO

PUBLIC r AS IntegerPUBLIC pox AS IntegerPUBLIC poy AS IntegerPUBLIC SUB _new()END

PUBLIC SUB Form_Open()r = 30END

PUBLIC SUB Button1_Click() area1.Clear pox = area1.Height / 2 poy = area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB(200, 190, 50) Draw.FillStyle = Fill.BackDiagonal Draw.FillStyle = Fill.Dense37 Draw.Circle(pox, poy, r) r = r + 10Draw.EndEND

Page 15: Ejemplo En Gamabas

PUBLIC SUB Button3_Click() ME.CloseEND

PUBLIC SUB Button2_Click()area1.Clear pox = area1.Height / 2 poy = area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB(200, 190, 50) Draw.FillStyle = Fill.Vertical Draw.FillStyle = Fill.Cross Draw.Circle(pox, poy, r) r = r - 10Draw.EndEND

PUBLIC SUB Button4_Click() DIM n1, n2, n3 AS IntegerRANDOMIZE n1 = Int(Rnd() * 1000)' TextBox1.Text = n1 area1.Clear pox = area1.Height / 2 poy = area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB(200, 190, 50) Draw.FillStyle = Fill.CrossDiagonal Draw.FillStyle = Fill.Cross Draw.Circle(pox, poy, n1) Draw.Ellipse(pox, poy, n1, n1) r = r - 10 n2 = Int(Rnd() * 10) Draw.Ellipse(pox, poy, n2, n2) Draw.Line(pox, poy, n2, n2) Draw.Rect(pox, poy, n2) n3 = Int(Rnd() * 10)END

Page 16: Ejemplo En Gamabas
Page 17: Ejemplo En Gamabas

5.- PROTECTOR DE PANTALLA

' Gambas class filePUBLIC SUB Form_Open()Timer1.Enabled = TRUETimer2.Enabled = TRUETimer3.Enabled = TRUETimer4.Enabled = TRUETimer5.Enabled = TRUEEND

PUBLIC SUB Timer1_Timer()DIM c1, c2, c, posy, posx AS IntegerC1 = Int(Rnd() * 700)C2 = Int(Rnd() * 700)C = Int(Rnd() * 20)posy = Area1.Height / 2posx = Area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB((160 + c1), (2 + c2), (c1 + C2)) ' coge los colores que se designen Draw.FillStyle = Fill.Solid Draw.Circle(posy, C2, C) Draw.EndEND

Page 18: Ejemplo En Gamabas

PUBLIC SUB Button1_Click()ME.CloseEND

PUBLIC SUB Timer2_Timer() DIM c1, c2, c AS IntegerC1 = Int(Rnd() * 1000)C2 = Int(Rnd() * 1000)C = Int(Rnd() * 400)' posy = Area1.Height / 2' posx = Area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB((160 + c1), (2 + c2), (c1 + C2)) ' coge los colores que se designen Draw.FillStyle = Fill.Diagonal Draw.Ellipse(C1, C2, C, c) Draw.EndEND

PUBLIC SUB Timer3_Timer() DIM c1, c2, c AS IntegerC1 = Int(Rnd() * 600)C2 = Int(Rnd() * 600)C = Int(Rnd() * 40)' posy = Area1.Height / 2' posx = Area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB((300 + c1), (7 + c2), (c1 + C2)) ' coge los colores que se designen Draw.FillStyle = Fill.Dense94 Draw.Line(C1, C2, C, c) Draw.EndEND

PUBLIC SUB Timer4_Timer() DIM c1, c2, c, r AS IntegerC1 = Int(Rnd() * 600)C2 = Int(Rnd() * 600)C = Int(Rnd() * 40)' posy = Area1.Height / 2' posx = Area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB((200 + c1), (5 + c2), (c1 + C2))

Page 19: Ejemplo En Gamabas

' coge los colores que se designen Draw.FillStyle = Fill.Dense94 Draw.Rect(C1, C2, c, c) Draw.EndEND

PUBLIC SUB Timer5_Timer() DIM c1, c2, c, r AS Integer IF Timer5.Delay > 10 THEN Area1.ClearTextBox2.Text = ""TextBox2.Text = TimerELSEC1 = Int(Rnd() * 600)C2 = Int(Rnd() * 600)C = Int(Rnd() * 40)' posy = Area1.Height / 2' posx = Area1.Width / 2 Draw.Begin(area1) Draw.FillColor = Color.RGB((200 + c1), (5 + c2), (c1 + C2)) ' coge los colores que se designen Draw.FillStyle = Fill.Dense94 'Draw.Polygon(C1, C2) Draw.End TextBox2.Text = TimerENDIFEND

Page 20: Ejemplo En Gamabas

6.- RELOJ DIGITAL

PUBLIC SUB Form_Open()timer1.Enabled = TRUEEND

PUBLIC SUB Timer1_Timer()timer1.Delay = 1000TextLabel1.Text = Time(Hour(Now), Minute(Now), Second(Now))END

PUBLIC SUB Button1_Click()Message.Info("Es facil programar en Gambas")ME.CLOSE END

PUBLIC SUB Button2_Click() Message.Delete("Ejemplo de Reloj Digital ") END

PUBLIC SUB Form_Activate() TextBox1.text = TextLabel1.Text = Time(Hour(Now))END

Page 21: Ejemplo En Gamabas
Page 22: Ejemplo En Gamabas

7.- VERIFICADOR DE # DE CEDULA

PUBLIC SUB Main()DIM NUM_CED, NOMBRE AS StringDIM A, B, C, D, E, F, G, H, I, J, K, L AS IntegerPRINT "INGRESE SU NOMBRE"INPUT NOMBREPRINT "INGRESE NUMERO DE CEDULA"INPUT NUM_CEDFOR A = 1 TO 9 STEP 1B = Str(Mid(NUM_CED, A, 1))C = A MOD 2IF C = 0 THEN H = H + BELSE G = B * 2IF G > 9 THEN C = G MOD 10D = Int(G / 10)E = C + DELSE

Page 23: Ejemplo En Gamabas

E = G ENDIF F = F + E ENDIF NEXT I = F + H J = I MOD 10 K = 10 - J L = Mid(NUM_CED, 1, 9) PRINT "EL NUMERO DE SU CEDULA ES...." & Str(L) & "-" & Str(K)END

8.- UTILIZACION DE FUNCIONES

' Gambas module filePRIVATE heroe AS superheroePRIVATE heroe1 AS superheroePRIVATE heroe2 AS superheroe'atributosPUBLIC SUB Main()' DIM heroe AS superheroe' DIM heroe1 AS superheroeheroe = NEW superheroe

Page 24: Ejemplo En Gamabas

heroe1 = NEW superheroeheroe2 = NEW superheroe

heroe.nombre = "AQUILES MEJIA"heroe.actor = "DRAGON BALL Z "heroe.habilidad = "JENQUI DAMA "heroe.imprime()

heroe1.nombre = "EDUARDO MEJIA "heroe1.actor = "SUPERMAN "heroe1.habilidad = "BOLAR POR LOS AIRES" heroe1.imprime()WITH heroe2.nombre = "Zorro".actor = "Antonio Bandera".habilidad = "Peliar Con La Espada".imprime()END WITH END

PUBLIC nombre AS StringPUBLIC actor AS StringPUBLIC habilidad AS String

Page 25: Ejemplo En Gamabas

PUBLIC FUNCTION imprime()'PRINT "Hola mi nombre es: " & Str(nombre) & " Mi personaje favorito es: " & Str(actor) & " Y su habilidad es: " & Str(habilidad) PRINT "Hola mi nombre es: " & nombre & " Mi personaje favorito es: " & actor & " Y su habilidad es: " & habilidad END

9.- CONVERTIDOR DE NUMEROS A LETRAS

' Gambas class filePUBLIC FUNCTION EnLetras(numero AS String) AS String DIM b, paso AS Integer DIM expresion, entero, deci, flag AS String flag = "N" FOR paso = 1 TO Len(numero) IF Mid(numero, paso, 1) = "." THEN flag = "S" ELSE IF flag = "N" THEN entero = entero & Mid(numero, paso, 1) 'Extae la parte entera del numero ELSE deci = deci & Mid(numero, paso, 1) 'Extrae la parte decimal del numero END IF END IF NEXT ' paso IF Len(deci) = 1 THEN

Page 26: Ejemplo En Gamabas

deci = deci & "0" END IF flag = "N" IF Val(numero) >= -999999999 AND Val(numero) <= 999999999 THEN 'si el numero esta dentro de 0 a 999.999.999 FOR paso = Len(entero) TO 1 STEP -1 b = Len(entero) - (paso - 1) SELECT CASE paso CASE 3, 6, 9 SELECT CASE Mid(entero, b, 1) CASE "1" IF Mid(entero, b + 1, 1) = "0" AND Mid(entero, b + 2, 1) = "0" THEN expresion = expresion & "Cien " ELSE expresion = expresion & "Ciento " END IF CASE "2" expresion = expresion & "Doscientos " CASE "3" expresion = expresion & "Trescientos " CASE "4" expresion = expresion & "Cuatrocientos " CASE "5" expresion = expresion & "Quinientos " CASE "6" expresion = expresion & "Seiscientos " CASE "7" expresion = expresion & "Setecientos " CASE "8" expresion = expresion & "Ochocientos " CASE "9" expresion = expresion & "Novecientos " END SELECT CASE 2, 5, 8 SELECT CASE Mid(entero, b, 1) CASE "1" IF Mid(entero, b + 1, 1) = "0" THEN flag = "S" expresion = expresion & "Diez " END IF IF Mid(entero, b + 1, 1) = "1" THEN flag = "S" expresion = expresion & "Once "

Page 27: Ejemplo En Gamabas

END IF IF Mid(entero, b + 1, 1) = "2" THEN flag = "S" expresion = expresion & "Doce " END IF IF Mid(entero, b + 1, 1) = "3" THEN flag = "S" expresion = expresion & "Trece " END IF IF Mid(entero, b + 1, 1) = "4" THEN flag = "S" expresion = expresion & "Catorce " END IF IF Mid(entero, b + 1, 1) = "5" THEN flag = "S" expresion = expresion & "Quince " END IF IF Mid(entero, b + 1, 1) > "5" THEN flag = "N" expresion = expresion & "Dieci" END IF CASE "2" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Veinte " flag = "S" ELSE expresion = expresion & "Veinti" flag = "N" END IF CASE "3" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Treinta " flag = "S" ELSE expresion = expresion & "Treinta y " flag = "N" END IF CASE "4" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Cuarenta " flag = "S"

Page 28: Ejemplo En Gamabas

ELSE expresion = expresion & "Cuarenta y " flag = "N" END IF CASE "5" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Cincuenta " flag = "S" ELSE expresion = expresion & "Cincuenta y " flag = "N" END IF CASE "6" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Sesenta " flag = "S" ELSE expresion = expresion & "Sesenta y " flag = "N" END IF CASE "7" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Setenta " flag = "S" ELSE expresion = expresion & "Setenta y " flag = "N" END IF CASE "8" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Ochenta " flag = "S" ELSE expresion = expresion & "Ochenta y " flag = "N" END IF CASE "9" IF Mid(entero, b + 1, 1) = "0" THEN expresion = expresion & "Noventa "

Page 29: Ejemplo En Gamabas

flag = "S" ELSE expresion = expresion & "Noventa y " flag = "N" END IF END SELECT CASE 1, 4, 7 SELECT CASE Mid(entero, b, 1) CASE "1" IF flag = "N" THEN IF paso = 1 THEN expresion = expresion & "Uno " ELSE expresion = expresion & "Un " END IF END IF CASE "2" IF flag = "N" THEN expresion = expresion & "Dos " END IF CASE "3" IF flag = "N" THEN expresion = expresion & "Tres " END IF CASE "4" IF flag = "N" THEN expresion = expresion & "Cuatro " END IF CASE "5" IF flag = "N" THEN expresion = expresion & "Cinco " END IF CASE "6" IF flag = "N" THEN expresion = expresion & "Seis " END IF CASE "7" IF flag = "N" THEN expresion = expresion & "Siete " END IF CASE "8" IF flag = "N" THEN

Page 30: Ejemplo En Gamabas

expresion = expresion & "Ocho " END IF CASE "9" IF flag = "N" THEN expresion = expresion & "Nueve " END IF END SELECT END SELECT IF paso = 4 THEN 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 expresion = expresion & "mil " END IF END IF IF paso = 7 THEN IF Len(entero) = 7 AND Mid(entero, 1, 1) = "1" THEN expresion = expresion & "Millón " ELSE expresion = expresion & "Millones " END IF END IF NEXT ' paso IF deci <> "" THEN IF Mid(entero, 1, 1) = "-" THEN 'si el numero es negativo expresion = "menos " & expresion & "con " & deci & "/100" ELSE expresion = expresion & "con " & deci & "/100" END IF ELSE IF Mid(entero, 1, 1) = "-" THEN 'si el numero es negativo expresion = "menos " & expresion ELSE expresion = expresion END IF END IF ELSE 'si el numero a convertir esta fuera del rango superior e inferior expresion = "" END IF TextBox2.Text = expresionEND FUNCTION

PUBLIC SUB Button1_Click()

Page 31: Ejemplo En Gamabas

ME.CloseEND

PUBLIC SUB TextBox1_KeyPress()IF Key.Code = 65293 THEN EnLetras(TextBox1.Text)ENDIFEND

10.- ENCONTRAR EL MAYOR, MENOR, INTERMEDIO DE UN NÚMERO

' Gambas module file'entre tres numeros distintos mayor medio menor igualPUBLIC SUB Main()DIM a, b, c AS Integera = 15b = 100c = 22IF a > b AND a > c THEN PRINT "El mayor es...:" & Str(a) IF b > c THEN

Page 32: Ejemplo En Gamabas

PRINT "El intermedio es...:" & Str(b) PRINT "El menor es...:" & Str(c) ELSE PRINT "El intermedio es...:" & Str(c) PRINT "El menor es...:" & Str(b) ENDIF ELSE IF b > c THEN PRINT "El mayor es...:" & Str(b) IF a > c THEN PRINT "El intermedio es...:" & Str(a) PRINT "El menor es...:" & Str(c) ELSE PRINT "El intermedio es...:" & Str(c)PRINT "El menor es...:" & Str(a) ENDIFELSE PRINT "El mayor es...:" & Str(c)IF a > b THENPRINT "El intermedio es...:" & Str(a)PRINT "El menor es...:" & Str(b)ELSE PRINT "El intermedio es...:" & Str(b)PRINT "El menor es...:" & Str(a) ENDIF ENDIF ENDIF END

Page 33: Ejemplo En Gamabas

11.- CRONOMETRO

Gambas class file PUBLIC SUB Timer1_Timer() SEG.Text = Val(SEG.Text) + 1 IF SEG.Text = 60 THEN MIN.Text = Val(MIN.Text) + 1 SEG.Text = 0 ENDIF IF MIN.Text = 60 THEN HOR.Text = Val(HOR.Text) + 1 MIN.Text = 0 ENDIF IF HOR.Text = 24 THEN HOR.Text = 0 ENDIF

Page 34: Ejemplo En Gamabas

END PUBLIC SUB Button1_Click() IF Button1.Text = "INICIAR" THEN Timer1.Enabled = TRUE Button1.Caption = "PARAR" ELSE IF Button1.Text = "PARAR" THEN Timer1.Enabled = FALSE Button1.Caption = "INICIAR" ENDIF ENDIF END PUBLIC SUB Button2_Click() Me.closeEND