SlideShare une entreprise Scribd logo
1  sur  16
Gambas
Es un lenguaje de programacion libre derivado de Basic.Se
distribuye con licencia GNU GPL. Cabe destacar que presenta
ciertas similitudes con javas ya que en la ejecución de cualquier
aplicación, se requiere un conjunto de librerías interprete
previamente instaladas.
Permite crear formularios con botones de comandos, cuadros de
texto y muchos otros controles y enlazarlos a base de datos.
Lenguaje de programacion sencillo para plataformas libres (como
GNU/Linux y BSD).
Este ejemplo nos permite realizar una resta.
PUBLIC SUB Main()
DIM a AS Integer
DIM b, r AS Integer
a = 50
b = 20
r = a - b
PRINT "la resta es"
PRINT "r"

END

Este programa nos permite encontrar el total de quintales.
EL Ecuador exporta café, cacao y maiz.
PUBLIC SUB Main()
DIM A, c, fe, m, s, p1, p2, p3 AS Integer
PRINT "ingrese una cantidad"
INPUT A
INPUT c, fe, m
PRINT "lo que ingreso es.....", A
PRINT "ingrese la cantidad de cacao"
INPUT c
PRINT "ingrese la cantidad de café"
INPUT fe
PRINT "ingrese la cantidad de maiz"
INPUT m
s = c + fe + m
p1 = (c * 100) / s
p2 = (fe * 100) / s
p3 = (m * 100) / s
PRINT "el total de importaciones es"
PRINT "el quintal de cacao es", & srt(s) & "entre p1 y p3"
PRINT "el quintal de café es"
PRINT "el quintal de maiz es"
END
Este programa nos permite conoser que número es Mayor, Menor, y
Medio
PUBLIC SUB Main()
DIM a, b, c AS Integer
PRINT "Ingrese primer valor A:"
INPUT a
PRINT "Ingrese segundo valor B:"
INPUT b
PRINT "Ingrese tercer valor C:"
INPUT c
IF ((a > b) AND (a > c)) THEN
  PRINT "Mayor", a
  IF (b > c) THEN
    PRINT "Medio", b
    PRINT "Menor", c
  ELSE
    PRINT "Medio", c
    PRINT "Menor", b
  ENDIF
ENDIF
IF ((b > c) AND (b > a)) THEN
  PRINT "Mayor", b
  IF (a > c) THEN
    PRINT "Medio", a
    PRINT "Menor", c
  ELSE
    PRINT "Medio", c
    PRINT "Menor", a
  ENDIF
ENDIF
IF ((c > b) AND (c > a)) THEN
  PRINT "Mayor", c
  IF (b > a) THEN
    PRINT "Medio", b
    PRINT "Menor", a
  ELSE
    PRINT "Medio", a
    PRINT "Menor", b
  ENDIF
ENDIF
END
Este ejercicio nos permite ingresar los datos de un estudiante con
mucha facilidad.
PRIVATE Promedio AS String
PRIVATE FechaMatricula AS Date
PRIVATE Nombre AS String
PRIVATE Apellido AS String
PRIVATE Nota1 AS Single
PRIVATE nota2 AS Single
PRIVATE nota3 AS Single

PUBLIC SUB notaUno(numero AS Integer)
  Nota1 = numero
END

PUBLIC SUB notaDos(numero AS Integer)
  nota2 = numero
END

PUBLIC SUB notaTres(numero AS Integer)
  nota3 = numero
END

PUBLIC FUNCTION PromedioFinal() AS Single
  RETURN (nota1 + nota2 + nota3) / 3
 END

PUBLIC FUNCTION fechama(fecha AS Date) AS Date
  FechaMatricula = fecha
  RETURN FechaMatricula
END

PUBLIC SUB PoneNombre(cadena AS String)
  Nombre = cadena
END

PUBLIC SUB PoneApellido(cadena AS String)
  Apellido = cadena
END

PUBLIC FUNCTION NombreCompleto() AS String
  RETURN Nombre & "" & Apellido
END
LA CALCULADORA
Este es un programa que nos permite realizar   las funciones de
una calculadora.




 Gambas class file
PUBLIC ban AS Integer
PUBLIC aux1 AS Integer
PUBLIC aux2 AS Integer
PUBLIC SUB _new()


END

PUBLIC SUB button1_Click()

  visor.Text = visor.Text & "1"

END

PUBLIC SUB Button4_Click()

   visor.Text = visor.Text & "4"


END
PUBLIC SUB Button2_Click()

   visor.Text = visor.Text & "2"

END

PUBLIC SUB Button3_Click()

   visor.Text = visor.Text & "3"

END

PUBLIC SUB Button5_Click()

   visor.Text = visor.Text & "5"

END

PUBLIC SUB Button6_Click()

   visor.Text = visor.Text & "6"

END

PUBLIC SUB Button7_Click()

   visor.Text = visor.Text & "7"

END

PUBLIC SUB Button8_Click()

   visor.Text = visor.Text & "8"

END

PUBLIC SUB Button9_Click()

   visor.Text = visor.Text & "9"

END

PUBLIC SUB Button10_Click()

   visor.Text = visor.Text & "0"
END

PUBLIC SUB Button11_Click()

   visor.Text = visor.Text & "."

END


PUBLIC SUB Button17_Click()

  visor.Clear

END

PUBLIC SUB Button18_Click()

  ME.Close

END

PUBLIC SUB Button13_Click()

  ban = 1
    IF visor.Text <> 0 THEN
    aux1 = visor.Text
    ELSE
      aux1 = 0
      ENDIF
      visor.Clear

END

PUBLIC SUB Button14_Click()

  ban = 2
    IF visor.Text <> 0 THEN
    aux1 = visor.Text
    ELSE
      aux1 = 0
      ENDIF
      visor.Clear

END
PUBLIC SUB Button15_Click()

  ban = 3
    IF visor.Text <> 0 THEN
    aux1 = visor.Text
    ELSE
      aux1 = 0
      ENDIF
      visor.Clear

END

PUBLIC SUB Button16_Click()

  ban = 4
    IF visor.Text <> 0 THEN
    aux1 = visor.Text
    ELSE
      aux1 = 0
      ENDIF
      visor.Clear

END

PUBLIC SUB Button20_Click()

  IF visor.Text <> 0 THEN
    aux2 = visor.Text
     ELSE
     aux2 = 0
     ENDIF
     visor.Text = operaciones(ban, aux1, aux2)
END
PUBLIC FUNCTION operaciones(opera AS Integer, v1 AS Integer, v2 AS
Integer) AS Integer
  DIM respuesta AS Integer
  SELECT CASE opera
  CASE 1
     respuesta = v1 + v2
  CASE 2
  respuesta = v1 - v2
  CASE 3
  respuesta = v1 * v2
  CASE 4
respuesta = v1 / v2

  END SELECT
  RETURN respuesta

END

PUBLIC SUB Button31_Click()
DIM n, i, x1, x2 AS Integer
DIM cadena, cadena2 AS String
  n = visor.Text
  WHILE n > 0
  x1 = (Int(n / 2))
  x2 = n MOD 2
  cadena = cadena & Str(x2)
  n = x1
  WEND
  FOR i = Len(cadena) TO 1 STEP -1
  cadena2 = cadena2 & Mid(cadena, i, 1)
  NEXT
  visor.Text = cadena2
  Messsage("el resultado es.....", "aceptar")




END

PUBLIC SUB Button32_Click()


DIM n, x1, x2, j AS Integer
DIM cadena, cadena2 AS String
n = visor.text
WHILE n > 0
x1 = (Int(n / 8))
x2 = n MOD 8
cadena = cadena & Str(x2)
n = x1
WEND
FOR j = Len(cadena) TO 1 STEP -1
cadena2 = cadena2 & Mid(cadena, j, 1)
NEXT
visor.text = cadena2
END
PUBLIC SUB Button23_Click()
visor.text = Sin(visor.text)




END

PUBLIC SUB Button24_Click()
visor.text = Cos(visor.text)


END

PUBLIC SUB Button25_Click()

  visor.text = Tan(visor.text)

END

PUBLIC SUB Button12_Click()

  visor.text = visor.text * visor.text

END

PUBLIC SUB Button19_Click()

  visor.text = visor.text * visor.text * visor.text

END

PUBLIC SUB Button33_Click()

DIM n, i, x1, x2 AS Integer
  DIM cadena, cadena2 AS String
  n = visor.Text
  WHILE n > 0
    x1 = (Int(n / 16))
    x2 = n MOD 16
    IF x2 < 10 THEN
     cadena = cadena & Str(x2)
    ELSE IF x2 = 10 THEN
     cadena = cadena & "A"
     ELSE IF X2 = 11 THEN
cadena = cadena & "B"
      ELSE IF x2 = 12 THEN
       cadena = cadena & "C"
       ELSE IF X2 = 13 THEN
       cadena = cadena & "D"
      ELSE IF x2 = 14 THEN
       cadena = cadena & "E"
       ELSE IF X2 = 15 THEN
       cadena = cadena & "F"
      ENDIF
           n = x1
      WEND
      FOR i = Len(cadena) TO 1 STEP -1
      cadena2 = cadena2 & Mid(cadena, i, 1)
      NEXT
      visor.Text = cadena2


END

PUBLIC SUB Button21_Click()




END

PUBLIC SUB Button27_Click()




END

PUBLIC SUB Button28_Click()




END
Este ejemplo nos permite hacer el ingreso de productos como a su
vez nos permite visualizar el estandar de productos existentes en
nuestra base de datos.




Gambas class file
PUBLIC con AS Integer
PUBLIC fil AS Integer
PUBLIC col AS Integer
PUBLIC SUB Form_Open()
modulo.conectar
modulo.rs = modulo.cn.Exec("select * from producto")
mostrar()
END

PUBLIC SUB Button5_Click()
ME.Close
END
'guarda

PUBLIC SUB Button9_Click()
TRY modulo.cn.Exec("insert into producto values('" &
Trim(UCase(TextBox8.Text)) & "','" & Trim(UCase(TextBox7.Text)) &
"','" & (TextBox6.Text) & "','" & (ValueBox1.Text) & "');")
IF ERROR THEN
Message.Error("Imposible insertar el registro")
ELSE
Message.Info("Registro insertado")
END IF
modulo.rs = modulo.cn.Exec("Select * from producto")
mostrar()
desabilitar()

END

PUBLIC SUB desabilitar()
  TextBox8.Enabled = FALSE
  TextBox7.Enabled = FALSE
  TextBox6.Enabled = FALSE
  ValueBox1.Enabled = FALSE
    END

PUBLIC SUB mostrar()
modulo.rs.MoveFirst
IF modulo.rs.Count > 0 THEN
Grid1.Columns.Count = 4
Grid1.Rows.Count = modulo.rs.Count + 1
Grid1.Columns[0].Width = 60
Grid1.Columns[1].Width = 180
Grid1.Columns[2].Width = 80
Grid1.Columns[3].Width = 80
Grid1[0, 0].Text = "Codigo"
Grid1[0, 1].Text = "Nombre"
Grid1[0, 2].Text = "Cantidad"
Grid1[0, 3].Text = "Precio Unitario"
fil = 1
modulo.rs.MoveFirst
'con = Modulo.rs.Count
DO WHILE modulo.rs.Available

Grid1[fil, 0].Text =   modulo.rs["codigo"]
Grid1[fil, 1].Text =   modulo.rs["nombre"]
Grid1[fil, 2].Text =   modulo.rs["precio"]
Grid1[fil, 3].Text =   modulo.rs["cantidad"]
fil = fil + 1
modulo.rs.MoveNext()
LOOP
ENDIF

END
PUBLIC SUB Button10_Click()

SELECT Message.Question("Desea eliminar un Producto", "Si", "No")
CASE 1
TRY modulo.cn.Exec("Delete from producto where codigo='" &
Trim(UCase(TextBox8.Text)) & "'")
IF ERROR THEN
Message.Error("Imposible borrar el registro")
ELSE
modulo.rs = modulo.cn.Exec("select * from producto")
mostrar()

END IF
CASE 2
Message.Info("Registro no eliminado")
CASE 3
END SELECT
'limpiar()

END


PUBLIC SUB Button11_Click()

TRY Modulo.cn.Exec("update producto set nombre='" &
Trim(UCase(TextBox7.Text)) & "',precio='" &
Trim(UCase(TextBox6.Text)) & "',cantidad='" &
Trim(UCase(ValueBox1.Text)) & "' where=textbox8.text ")
IF ERROR THEN
Message.Error("Imposible actualizar el registro")
ELSE
Message.Info("Registro actualizado")
END IF

mostrar
'LIMPIAR

END


PUBLIC SUB Button8_Click()

TextBox8.Clear
TextBox7.Clear
TextBox6.Clear
TextBox6.Text = 0
ValueBox1.Clear
abilitar()
END


PUBLIC SUB abilitar()
  TextBox8.Enabled = TRUE
  TextBox7.Enabled = TRUE
  TextBox6.Enabled = TRUE
  ValueBox1.Enabled = TRUE
    END
PUBLIC SUB Grid1_Click()

IF Grid1.Current = NULL THEN RETURN
SELECT Message.Question("Desea eliminar un producto", "Si", "No",
"Ayuda")
CASE 1
TRY modulo.cn.Exec("Delete from producto where codigo='" &
Trim(UCase(Grid1.Current.Text)) & "'")
IF ERROR THEN
Message.Error("Imposible borrar el registro")
ELSE
modulo.rs = modulo.cn.Exec("select * from producto")
mostrar()

END IF
CASE 2
Message.Info("Registro no eliminado")

END SELECT

END

PUBLIC SUB Button7_Click()
DIM ban AS Integer
Modulo.rs = Modulo.cn.Exec("select * from producto")
DO WHILE Modulo.rs.Available

IF modulo.rs["codigo"] = Trim(UCase(TextBox8.Text)) THEN
Modulo.rs = Modulo.cn.Exec("select * from producto where codigo =
'" & Trim(UCase(TextBox8.Text)) & "'")
TextBox7.Text = Modulo.rs["nombre"]
TextBox6.Text = Modulo.rs["precio"]
ValueBox1.Value = Modulo.rs["cantidad"]
ban = 1
ENDIF
MODULO.rs.MoveNext()
LOOP
IF ban = 0 THEN
Message.Error("Registro Invalido")
'limpiar()
END IF

END

PUBLIC SUB Button1_Click()

  ME.Close

END
PUBLIC SUB TextBox7_KeyPress()
IF Key.code = 65293 THEN
IF TextBox7.Text = "" THEN
Message.Info("iNGRESE NOMBRE DE PRODUCTO0...")
TextBox7.Select
ELSE
TextBox6.SetFocus
ENDIF
  ENDIF

 END

PUBLIC SUB TextBox6_KeyPress()

  IF Key.code = 65293 THEN
  IF TextBox6.Text = "" THEN
Message.Info("PRECIO DEL PRODUCTO0...")
TextBox6.Select
ELSE
ValueBox1.SetFocus
ENDIF
  ENDIF


END

PUBLIC SUB ValueBox1_KeyPress()
IF Key.code = 65293 THEN
  IF ValueBox1 = "" THEN
Message.Info("INGRESE CANTIDAD DEL PRODUCTO0...")
ValueBox1.Select
ELSE
TextBox8.SetFocus
ENDIF
  ENDIF


END

Contenu connexe

Tendances

Trabajo Para Subir
Trabajo Para SubirTrabajo Para Subir
Trabajo Para Subirguest9da3a3
 
Trabajo Para Subir
Trabajo Para SubirTrabajo Para Subir
Trabajo Para Subirguest9da3a3
 
Burger doll order form
Burger doll order formBurger doll order form
Burger doll order formKhairi Aiman
 
Codigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De GambasCodigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De Gambasmikyken
 
The Ring programming language version 1.5.3 book - Part 46 of 184
The Ring programming language version 1.5.3 book - Part 46 of 184The Ring programming language version 1.5.3 book - Part 46 of 184
The Ring programming language version 1.5.3 book - Part 46 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 36 of 88
The Ring programming language version 1.3 book - Part 36 of 88The Ring programming language version 1.3 book - Part 36 of 88
The Ring programming language version 1.3 book - Part 36 of 88Mahmoud Samir Fayed
 
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...tdc-globalcode
 
Calculadora
CalculadoraCalculadora
CalculadoraCBTa 120
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPaweł Dawczak
 
Database Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, JoinDatabase Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, JoinAl-Mamun Sarkar
 

Tendances (15)

Trabajo Para Subir
Trabajo Para SubirTrabajo Para Subir
Trabajo Para Subir
 
Trabajo Para Subir
Trabajo Para SubirTrabajo Para Subir
Trabajo Para Subir
 
Burger doll order form
Burger doll order formBurger doll order form
Burger doll order form
 
Gambas
Gambas Gambas
Gambas
 
Draw2D
Draw2DDraw2D
Draw2D
 
Codigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De GambasCodigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De Gambas
 
The Ring programming language version 1.5.3 book - Part 46 of 184
The Ring programming language version 1.5.3 book - Part 46 of 184The Ring programming language version 1.5.3 book - Part 46 of 184
The Ring programming language version 1.5.3 book - Part 46 of 184
 
The Ring programming language version 1.3 book - Part 36 of 88
The Ring programming language version 1.3 book - Part 36 of 88The Ring programming language version 1.3 book - Part 36 of 88
The Ring programming language version 1.3 book - Part 36 of 88
 
Writeable CTEs: The Next Big Thing
Writeable CTEs: The Next Big ThingWriteable CTEs: The Next Big Thing
Writeable CTEs: The Next Big Thing
 
Ensayo
EnsayoEnsayo
Ensayo
 
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
TDC2017 | São Paulo - Trilha Programação Funcional How we figured out we had ...
 
Area de un triangulo
Area de un trianguloArea de un triangulo
Area de un triangulo
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Pre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to ElixirPre-Bootcamp introduction to Elixir
Pre-Bootcamp introduction to Elixir
 
Database Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, JoinDatabase Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, Join
 

En vedette

5 thingsyouneedtoknow (1)
5 thingsyouneedtoknow (1)5 thingsyouneedtoknow (1)
5 thingsyouneedtoknow (1)B Jitu
 
Blanqui
BlanquiBlanqui
Blanquirosyp
 
Storage Systems for High Scalable Systems Presentation
Storage Systems for High Scalable Systems PresentationStorage Systems for High Scalable Systems Presentation
Storage Systems for High Scalable Systems Presentationandyman3000
 
Jim conard presentation
Jim conard presentationJim conard presentation
Jim conard presentationJim Conard
 
jQuery与Asp.Net3.5开发Ajax化的Web应用程序
jQuery与Asp.Net3.5开发Ajax化的Web应用程序jQuery与Asp.Net3.5开发Ajax化的Web应用程序
jQuery与Asp.Net3.5开发Ajax化的Web应用程序killuakun
 
Soalan upsr math 1 siri 1
Soalan upsr math 1 siri 1Soalan upsr math 1 siri 1
Soalan upsr math 1 siri 1sraisb
 
Majalah
MajalahMajalah
Majalahsraisb
 
Bubur lambuk perdana 17 julai 2012
Bubur lambuk perdana 17 julai 2012Bubur lambuk perdana 17 julai 2012
Bubur lambuk perdana 17 julai 2012sraisb
 
How to Write a Press Release &amp; What to do when the Media Calls
How to Write a Press Release &amp; What to do when the Media CallsHow to Write a Press Release &amp; What to do when the Media Calls
How to Write a Press Release &amp; What to do when the Media CallsDrummond Public Relations
 
Journalism Ethics
Journalism EthicsJournalism Ethics
Journalism EthicsTommyAbate
 

En vedette (16)

Portofoliu
PortofoliuPortofoliu
Portofoliu
 
5 thingsyouneedtoknow (1)
5 thingsyouneedtoknow (1)5 thingsyouneedtoknow (1)
5 thingsyouneedtoknow (1)
 
Blanqui
BlanquiBlanqui
Blanqui
 
Storage Systems for High Scalable Systems Presentation
Storage Systems for High Scalable Systems PresentationStorage Systems for High Scalable Systems Presentation
Storage Systems for High Scalable Systems Presentation
 
Jim conard presentation
Jim conard presentationJim conard presentation
Jim conard presentation
 
MGM Grand Preview
MGM Grand PreviewMGM Grand Preview
MGM Grand Preview
 
jQuery与Asp.Net3.5开发Ajax化的Web应用程序
jQuery与Asp.Net3.5开发Ajax化的Web应用程序jQuery与Asp.Net3.5开发Ajax化的Web应用程序
jQuery与Asp.Net3.5开发Ajax化的Web应用程序
 
PWNH Presentation
PWNH PresentationPWNH Presentation
PWNH Presentation
 
Soalan upsr math 1 siri 1
Soalan upsr math 1 siri 1Soalan upsr math 1 siri 1
Soalan upsr math 1 siri 1
 
Majalah
MajalahMajalah
Majalah
 
Bubur lambuk perdana 17 julai 2012
Bubur lambuk perdana 17 julai 2012Bubur lambuk perdana 17 julai 2012
Bubur lambuk perdana 17 julai 2012
 
How to Write a Press Release &amp; What to do when the Media Calls
How to Write a Press Release &amp; What to do when the Media CallsHow to Write a Press Release &amp; What to do when the Media Calls
How to Write a Press Release &amp; What to do when the Media Calls
 
Database Testing
Database TestingDatabase Testing
Database Testing
 
Why You Complain
Why You ComplainWhy You Complain
Why You Complain
 
Secrets Exposed
Secrets ExposedSecrets Exposed
Secrets Exposed
 
Journalism Ethics
Journalism EthicsJournalism Ethics
Journalism Ethics
 

Similaire à Yolygambas

Programas Gambas
Programas GambasProgramas Gambas
Programas GambasRZYMJ
 
Trabajo Para Subir
Trabajo Para SubirTrabajo Para Subir
Trabajo Para Subirguest9da3a3
 
Codigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De GambasCodigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De Gambasmikyken
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxjeyel85227
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1rajnidhiman
 
PART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHONPART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHONAndrea Antonello
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAPsapdocs. info
 
01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.pptFerdieBalang
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowchartsSamuel Igbanogu
 

Similaire à Yolygambas (20)

Programas Gambas
Programas GambasProgramas Gambas
Programas Gambas
 
Trabajo Para Subir
Trabajo Para SubirTrabajo Para Subir
Trabajo Para Subir
 
Programas Gambas
Programas GambasProgramas Gambas
Programas Gambas
 
Codigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De GambasCodigo Fuente De Ejercicios De Gambas
Codigo Fuente De Ejercicios De Gambas
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Calculadora
CalculadoraCalculadora
Calculadora
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
 
Ejercicios
EjerciciosEjercicios
Ejercicios
 
Ejercicios
EjerciciosEjercicios
Ejercicios
 
Ejerciciosdeprogramacion
EjerciciosdeprogramacionEjerciciosdeprogramacion
Ejerciciosdeprogramacion
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
PART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHONPART 3: THE SCRIPTING COMPOSER AND PYTHON
PART 3: THE SCRIPTING COMPOSER AND PYTHON
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 

Yolygambas

  • 1. Gambas Es un lenguaje de programacion libre derivado de Basic.Se distribuye con licencia GNU GPL. Cabe destacar que presenta ciertas similitudes con javas ya que en la ejecución de cualquier aplicación, se requiere un conjunto de librerías interprete previamente instaladas. Permite crear formularios con botones de comandos, cuadros de texto y muchos otros controles y enlazarlos a base de datos. Lenguaje de programacion sencillo para plataformas libres (como GNU/Linux y BSD). Este ejemplo nos permite realizar una resta. PUBLIC SUB Main() DIM a AS Integer DIM b, r AS Integer a = 50 b = 20 r = a - b PRINT "la resta es" PRINT "r" END Este programa nos permite encontrar el total de quintales. EL Ecuador exporta café, cacao y maiz. PUBLIC SUB Main() DIM A, c, fe, m, s, p1, p2, p3 AS Integer PRINT "ingrese una cantidad" INPUT A INPUT c, fe, m PRINT "lo que ingreso es.....", A PRINT "ingrese la cantidad de cacao" INPUT c PRINT "ingrese la cantidad de café" INPUT fe PRINT "ingrese la cantidad de maiz" INPUT m s = c + fe + m p1 = (c * 100) / s p2 = (fe * 100) / s p3 = (m * 100) / s PRINT "el total de importaciones es" PRINT "el quintal de cacao es", & srt(s) & "entre p1 y p3" PRINT "el quintal de café es" PRINT "el quintal de maiz es" END
  • 2. Este programa nos permite conoser que número es Mayor, Menor, y Medio PUBLIC SUB Main() DIM a, b, c AS Integer PRINT "Ingrese primer valor A:" INPUT a PRINT "Ingrese segundo valor B:" INPUT b PRINT "Ingrese tercer valor C:" INPUT c IF ((a > b) AND (a > c)) THEN PRINT "Mayor", a IF (b > c) THEN PRINT "Medio", b PRINT "Menor", c ELSE PRINT "Medio", c PRINT "Menor", b ENDIF ENDIF IF ((b > c) AND (b > a)) THEN PRINT "Mayor", b IF (a > c) THEN PRINT "Medio", a PRINT "Menor", c ELSE PRINT "Medio", c PRINT "Menor", a ENDIF ENDIF IF ((c > b) AND (c > a)) THEN PRINT "Mayor", c IF (b > a) THEN PRINT "Medio", b PRINT "Menor", a ELSE PRINT "Medio", a PRINT "Menor", b ENDIF ENDIF END
  • 3. Este ejercicio nos permite ingresar los datos de un estudiante con mucha facilidad. PRIVATE Promedio AS String PRIVATE FechaMatricula AS Date PRIVATE Nombre AS String PRIVATE Apellido AS String PRIVATE Nota1 AS Single PRIVATE nota2 AS Single PRIVATE nota3 AS Single PUBLIC SUB notaUno(numero AS Integer) Nota1 = numero END PUBLIC SUB notaDos(numero AS Integer) nota2 = numero END PUBLIC SUB notaTres(numero AS Integer) nota3 = numero END PUBLIC FUNCTION PromedioFinal() AS Single RETURN (nota1 + nota2 + nota3) / 3 END PUBLIC FUNCTION fechama(fecha AS Date) AS Date FechaMatricula = fecha RETURN FechaMatricula END PUBLIC SUB PoneNombre(cadena AS String) Nombre = cadena END PUBLIC SUB PoneApellido(cadena AS String) Apellido = cadena END PUBLIC FUNCTION NombreCompleto() AS String RETURN Nombre & "" & Apellido END
  • 4. LA CALCULADORA Este es un programa que nos permite realizar las funciones de una calculadora. Gambas class file PUBLIC ban AS Integer PUBLIC aux1 AS Integer PUBLIC aux2 AS Integer PUBLIC SUB _new() END PUBLIC SUB button1_Click() visor.Text = visor.Text & "1" END PUBLIC SUB Button4_Click() visor.Text = visor.Text & "4" END
  • 5. PUBLIC SUB Button2_Click() visor.Text = visor.Text & "2" END PUBLIC SUB Button3_Click() visor.Text = visor.Text & "3" END PUBLIC SUB Button5_Click() visor.Text = visor.Text & "5" END PUBLIC SUB Button6_Click() visor.Text = visor.Text & "6" END PUBLIC SUB Button7_Click() visor.Text = visor.Text & "7" END PUBLIC SUB Button8_Click() visor.Text = visor.Text & "8" END PUBLIC SUB Button9_Click() visor.Text = visor.Text & "9" END PUBLIC SUB Button10_Click() visor.Text = visor.Text & "0"
  • 6. END PUBLIC SUB Button11_Click() visor.Text = visor.Text & "." END PUBLIC SUB Button17_Click() visor.Clear END PUBLIC SUB Button18_Click() ME.Close END PUBLIC SUB Button13_Click() ban = 1 IF visor.Text <> 0 THEN aux1 = visor.Text ELSE aux1 = 0 ENDIF visor.Clear END PUBLIC SUB Button14_Click() ban = 2 IF visor.Text <> 0 THEN aux1 = visor.Text ELSE aux1 = 0 ENDIF visor.Clear END
  • 7. PUBLIC SUB Button15_Click() ban = 3 IF visor.Text <> 0 THEN aux1 = visor.Text ELSE aux1 = 0 ENDIF visor.Clear END PUBLIC SUB Button16_Click() ban = 4 IF visor.Text <> 0 THEN aux1 = visor.Text ELSE aux1 = 0 ENDIF visor.Clear END PUBLIC SUB Button20_Click() IF visor.Text <> 0 THEN aux2 = visor.Text ELSE aux2 = 0 ENDIF visor.Text = operaciones(ban, aux1, aux2) END PUBLIC FUNCTION operaciones(opera AS Integer, v1 AS Integer, v2 AS Integer) AS Integer DIM respuesta AS Integer SELECT CASE opera CASE 1 respuesta = v1 + v2 CASE 2 respuesta = v1 - v2 CASE 3 respuesta = v1 * v2 CASE 4
  • 8. respuesta = v1 / v2 END SELECT RETURN respuesta END PUBLIC SUB Button31_Click() DIM n, i, x1, x2 AS Integer DIM cadena, cadena2 AS String n = visor.Text WHILE n > 0 x1 = (Int(n / 2)) x2 = n MOD 2 cadena = cadena & Str(x2) n = x1 WEND FOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & Mid(cadena, i, 1) NEXT visor.Text = cadena2 Messsage("el resultado es.....", "aceptar") END PUBLIC SUB Button32_Click() DIM n, x1, x2, j AS Integer DIM cadena, cadena2 AS String n = visor.text WHILE n > 0 x1 = (Int(n / 8)) x2 = n MOD 8 cadena = cadena & Str(x2) n = x1 WEND FOR j = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & Mid(cadena, j, 1) NEXT visor.text = cadena2 END
  • 9. PUBLIC SUB Button23_Click() visor.text = Sin(visor.text) END PUBLIC SUB Button24_Click() visor.text = Cos(visor.text) END PUBLIC SUB Button25_Click() visor.text = Tan(visor.text) END PUBLIC SUB Button12_Click() visor.text = visor.text * visor.text END PUBLIC SUB Button19_Click() visor.text = visor.text * visor.text * visor.text END PUBLIC SUB Button33_Click() DIM n, i, x1, x2 AS Integer DIM cadena, cadena2 AS String n = visor.Text WHILE n > 0 x1 = (Int(n / 16)) x2 = n MOD 16 IF x2 < 10 THEN cadena = cadena & Str(x2) ELSE IF x2 = 10 THEN cadena = cadena & "A" ELSE IF X2 = 11 THEN
  • 10. cadena = cadena & "B" ELSE IF x2 = 12 THEN cadena = cadena & "C" ELSE IF X2 = 13 THEN cadena = cadena & "D" ELSE IF x2 = 14 THEN cadena = cadena & "E" ELSE IF X2 = 15 THEN cadena = cadena & "F" ENDIF n = x1 WEND FOR i = Len(cadena) TO 1 STEP -1 cadena2 = cadena2 & Mid(cadena, i, 1) NEXT visor.Text = cadena2 END PUBLIC SUB Button21_Click() END PUBLIC SUB Button27_Click() END PUBLIC SUB Button28_Click() END
  • 11. Este ejemplo nos permite hacer el ingreso de productos como a su vez nos permite visualizar el estandar de productos existentes en nuestra base de datos. Gambas class file PUBLIC con AS Integer PUBLIC fil AS Integer PUBLIC col AS Integer PUBLIC SUB Form_Open() modulo.conectar modulo.rs = modulo.cn.Exec("select * from producto") mostrar() END PUBLIC SUB Button5_Click() ME.Close END 'guarda PUBLIC SUB Button9_Click() TRY modulo.cn.Exec("insert into producto values('" & Trim(UCase(TextBox8.Text)) & "','" & Trim(UCase(TextBox7.Text)) & "','" & (TextBox6.Text) & "','" & (ValueBox1.Text) & "');") IF ERROR THEN
  • 12. Message.Error("Imposible insertar el registro") ELSE Message.Info("Registro insertado") END IF modulo.rs = modulo.cn.Exec("Select * from producto") mostrar() desabilitar() END PUBLIC SUB desabilitar() TextBox8.Enabled = FALSE TextBox7.Enabled = FALSE TextBox6.Enabled = FALSE ValueBox1.Enabled = FALSE END PUBLIC SUB mostrar() modulo.rs.MoveFirst IF modulo.rs.Count > 0 THEN Grid1.Columns.Count = 4 Grid1.Rows.Count = modulo.rs.Count + 1 Grid1.Columns[0].Width = 60 Grid1.Columns[1].Width = 180 Grid1.Columns[2].Width = 80 Grid1.Columns[3].Width = 80 Grid1[0, 0].Text = "Codigo" Grid1[0, 1].Text = "Nombre" Grid1[0, 2].Text = "Cantidad" Grid1[0, 3].Text = "Precio Unitario" fil = 1 modulo.rs.MoveFirst 'con = Modulo.rs.Count DO WHILE modulo.rs.Available Grid1[fil, 0].Text = modulo.rs["codigo"] Grid1[fil, 1].Text = modulo.rs["nombre"] Grid1[fil, 2].Text = modulo.rs["precio"] Grid1[fil, 3].Text = modulo.rs["cantidad"] fil = fil + 1 modulo.rs.MoveNext() LOOP ENDIF END
  • 13. PUBLIC SUB Button10_Click() SELECT Message.Question("Desea eliminar un Producto", "Si", "No") CASE 1 TRY modulo.cn.Exec("Delete from producto where codigo='" & Trim(UCase(TextBox8.Text)) & "'") IF ERROR THEN Message.Error("Imposible borrar el registro") ELSE modulo.rs = modulo.cn.Exec("select * from producto") mostrar() END IF CASE 2 Message.Info("Registro no eliminado") CASE 3 END SELECT 'limpiar() END PUBLIC SUB Button11_Click() TRY Modulo.cn.Exec("update producto set nombre='" & Trim(UCase(TextBox7.Text)) & "',precio='" & Trim(UCase(TextBox6.Text)) & "',cantidad='" & Trim(UCase(ValueBox1.Text)) & "' where=textbox8.text ") IF ERROR THEN Message.Error("Imposible actualizar el registro") ELSE Message.Info("Registro actualizado") END IF mostrar 'LIMPIAR END PUBLIC SUB Button8_Click() TextBox8.Clear
  • 14. TextBox7.Clear TextBox6.Clear TextBox6.Text = 0 ValueBox1.Clear abilitar() END PUBLIC SUB abilitar() TextBox8.Enabled = TRUE TextBox7.Enabled = TRUE TextBox6.Enabled = TRUE ValueBox1.Enabled = TRUE END PUBLIC SUB Grid1_Click() IF Grid1.Current = NULL THEN RETURN SELECT Message.Question("Desea eliminar un producto", "Si", "No", "Ayuda") CASE 1 TRY modulo.cn.Exec("Delete from producto where codigo='" & Trim(UCase(Grid1.Current.Text)) & "'") IF ERROR THEN Message.Error("Imposible borrar el registro") ELSE modulo.rs = modulo.cn.Exec("select * from producto") mostrar() END IF CASE 2 Message.Info("Registro no eliminado") END SELECT END PUBLIC SUB Button7_Click() DIM ban AS Integer Modulo.rs = Modulo.cn.Exec("select * from producto") DO WHILE Modulo.rs.Available IF modulo.rs["codigo"] = Trim(UCase(TextBox8.Text)) THEN Modulo.rs = Modulo.cn.Exec("select * from producto where codigo = '" & Trim(UCase(TextBox8.Text)) & "'") TextBox7.Text = Modulo.rs["nombre"]
  • 15. TextBox6.Text = Modulo.rs["precio"] ValueBox1.Value = Modulo.rs["cantidad"] ban = 1 ENDIF MODULO.rs.MoveNext() LOOP IF ban = 0 THEN Message.Error("Registro Invalido") 'limpiar() END IF END PUBLIC SUB Button1_Click() ME.Close END PUBLIC SUB TextBox7_KeyPress() IF Key.code = 65293 THEN IF TextBox7.Text = "" THEN Message.Info("iNGRESE NOMBRE DE PRODUCTO0...") TextBox7.Select ELSE TextBox6.SetFocus ENDIF ENDIF END PUBLIC SUB TextBox6_KeyPress() IF Key.code = 65293 THEN IF TextBox6.Text = "" THEN Message.Info("PRECIO DEL PRODUCTO0...") TextBox6.Select ELSE ValueBox1.SetFocus ENDIF ENDIF END PUBLIC SUB ValueBox1_KeyPress()
  • 16. IF Key.code = 65293 THEN IF ValueBox1 = "" THEN Message.Info("INGRESE CANTIDAD DEL PRODUCTO0...") ValueBox1.Select ELSE TextBox8.SetFocus ENDIF ENDIF END