SlideShare a Scribd company logo
Calculadora en la programación en GAMBAS



PUBLIC CAN AS Integer
PUBLIC OPE1 AS Single
PUBLIC OPE2 AS Single


PUBLIC SUB _new()

END

PUBLIC SUB Form_Open()

END

PUBLIC SUB Button17_Click()

 TextBox1.Clear()

END

PUBLIC SUB Button18_Click()

 ME.Close(0)

END

PUBLIC SUB Button12_Click()

 TextBox1.Text = TextBox1.Text & "0"

END

PUBLIC SUB Button13_Click()

 TextBox1.Text = TextBox1.Text & "."

END

PUBLIC SUB Button7_Click()

 TextBox1.Text = TextBox1.Text & "1"

END

PUBLIC SUB Button8_Click()

 TextBox1.Text = TextBox1.Text & "2"
END

PUBLIC SUB Button9_Click()

 TextBox1.Text = TextBox1.Text & "3"

END

PUBLIC SUB Button4_Click()

 TextBox1.Text = TextBox1.Text & "4"

END

PUBLIC SUB Button5_Click()

 TextBox1.Text = TextBox1.Text & "5"

END

PUBLIC SUB Button6_Click()

 TextBox1.Text = TextBox1.Text & "6"

END

PUBLIC SUB Button1_Click()

 TextBox1.Text = TextBox1.Text & "7"

END

PUBLIC SUB Button2_Click()

 TextBox1.Text = TextBox1.Text & "8"

END

PUBLIC SUB Button3_Click()

 TextBox1.Text = TextBox1.Text & "9"

END

PUBLIC SUB Button10_Click()

 CAN = 4

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
ENDIF
   TextBox1.Clear

END

PUBLIC SUB Button15_Click()

 CAN = 1

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Clear

END

PUBLIC SUB Button14_Click()
CAN = 2

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Clear


END

PUBLIC SUB Button11_Click()

 CAN = 3

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Clear

END

PUBLIC SUB Button16_Click()



  IF TextBox1.Text <> 0 THEN
   OPE2 = TextBox1.Text
   ELSE
   OPE2 = 0
ENDIF

   TextBox1.Text = operacion(OPE1, OPE2, CAN)

END
PUBLIC FUNCTION operacion(v1 AS Float, v2 AS Float, opera AS Integer) AS Float

DIM re AS Float
DIM X, Y, Z, X1, Y1, Z1, X2, Y2, Z2, f, i AS Integer

 DIM XX, MEA AS String

 SELECT CASE opera

 CASE 1
   re = v1 + v2
 CASE 2
   re = v1 - v2
 CASE 3
  re = v1 * v2
 CASE 4
  re = v1 / v2
 CASE 5
  re = (v1 * v2) / 100
 CASE 6
  re = v1 ^ 2
  Z2 = 1
 CASE 7
  re = v1 ^ 3
  Z2 = 1
 CASE 8
  re = v1 ^ v2
  Z2 = 1
 CASE 9
  re = 1 / v1
  Z2 = 1
 CASE 10
  f=1
  FOR i = 1 TO v1
  f=f*i
  NEXT
  re = f
  Z2 = 1


 END SELECT
 IF Z2 = 1 THEN
 RETURN re
 ELSE
 RETURN Y1
 ENDIF
END
PUBLIC SUB Button19_Click()

CAN = 5

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Clear

END

PUBLIC SUB Button20_Click()

CAN = 6

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Text = OPE1


END

PUBLIC SUB Button21_Click()
'numero binario
DIM valor, x1, x2, i AS Integer
DIM 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 Button22_Click()
'Calculo a octal de un número decimal
DIM valor, x1, x2, i AS Integer
DIM cadena, cadena2 AS String
' IF visor.Text <> 0 THEN
   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 Button23_Click()
'Calculo a hexadecimal de un número decimal
DIM valor, x1, x2, i AS Integer
DIM 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()
CAN = 7

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Text = OPE1


END

PUBLIC SUB Button25_Click()
CAN = 8

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Text = OPE1


END

PUBLIC SUB Button28_Click()

 DIM k AS Float
 k = Rad(TextBox1.Text)
  TextBox1.Text = Sin(k)

END

PUBLIC SUB Button29_Click()

 DIM k AS Float
 k = Rad(TextBox1.Text)
 TextBox1.Text = Cos(k)

END
PUBLIC SUB Button30_Click()

 DIM k AS Float
k = Rad(TextBox1.Text)
 TextBox1.Text = Tan(k)

END

PUBLIC SUB Button26_Click()

 CAN = 9

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Text = OPE2

END

PUBLIC SUB Button27_Click()

 CAN = 10

  IF TextBox1.Text <> 0 THEN
   OPE1 = TextBox1.Text
   ELSE
   OPE1 = 0
   ENDIF
   TextBox1.Text = OPE2

END

More Related Content

DOC
Calculadora
cristinaverduga
 
DOC
Ejemplo En Gamabas
eduann
 
DOC
ejemplos gambas
eduann
 
ODT
Yolygambas
guest286373
 
PPTX
Ejercicios En Gambas
mafermen7
 
DOC
Area de un triangulo
Ivan Ramirez Iglesias
 
DOCX
Burger doll order form
Khairi Aiman
 
Calculadora
cristinaverduga
 
Ejemplo En Gamabas
eduann
 
ejemplos gambas
eduann
 
Yolygambas
guest286373
 
Ejercicios En Gambas
mafermen7
 
Area de un triangulo
Ivan Ramirez Iglesias
 
Burger doll order form
Khairi Aiman
 

What's hot (7)

PDF
Beginning web programming with PHP [PHP 101-02]
Mozammel Haque
 
PDF
The Ring programming language version 1.5.3 book - Part 46 of 184
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.3 book - Part 36 of 88
Mahmoud Samir Fayed
 
DOC
52 excel rupees converter formulae
ravikirang42
 
DOC
Protector De Pantalla
cristinaverduga
 
DOC
Windows XP Home / Pro Run Commands an...
Praveen Sudarsan
 
PDF
Ict project pdf
Happy Nezza Aranjuez
 
Beginning web programming with PHP [PHP 101-02]
Mozammel Haque
 
The Ring programming language version 1.5.3 book - Part 46 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 36 of 88
Mahmoud Samir Fayed
 
52 excel rupees converter formulae
ravikirang42
 
Protector De Pantalla
cristinaverduga
 
Windows XP Home / Pro Run Commands an...
Praveen Sudarsan
 
Ict project pdf
Happy Nezza Aranjuez
 
Ad

Viewers also liked (12)

PPTX
Intro
Innotect
 
PPTX
Los balones del mundi al
sebasyerbas33
 
ODP
Iciar Bollaín
boitiomero998
 
PDF
018 4913 thought conditioners 2014
Amy Nichole Davidson PhD
 
PPTX
Social Media for Marketing
xjoemanx
 
PPTX
Sdsds
zacharpali
 
PPTX
認識宜蘭縣自然資優方案
bell5
 
PDF
Invito gratuito
hormann1
 
PDF
417508
halay
 
PPTX
Procés tecnologic 2
oniasame
 
PPTX
Mule system properties
Karnam Karthik
 
PPTX
Self employment
economiahuelin
 
Intro
Innotect
 
Los balones del mundi al
sebasyerbas33
 
Iciar Bollaín
boitiomero998
 
018 4913 thought conditioners 2014
Amy Nichole Davidson PhD
 
Social Media for Marketing
xjoemanx
 
Sdsds
zacharpali
 
認識宜蘭縣自然資優方案
bell5
 
Invito gratuito
hormann1
 
417508
halay
 
Procés tecnologic 2
oniasame
 
Mule system properties
Karnam Karthik
 
Self employment
economiahuelin
 
Ad

Similar to Calculadora (20)

PPT
Ejemplo En Gambas
eduann
 
ODT
Yolygambas
guest286373
 
ODT
Yolygambas
rosyp
 
DOC
Ejerciciosdeprogramacion
Carmen Bermello Barreiro
 
DOC
Proyecto Blob
guest394b4d3
 
DOCX
Proyecto 2er Parcial
Yuliana9_7
 
DOCX
Yuliana
Yulissa98564
 
DOC
Gambas
guestae07b6
 
ODT
Trabajo Para Subir
guest9da3a3
 
DOC
Programas Gambas
RZYMJ
 
DOC
Programas Gambas
guestdd103d
 
ODT
Trabajo Para Subir
guest9da3a3
 
ODT
Trabajo Para Subir
guest9da3a3
 
ODT
Trabajo Para Subir
guest9da3a3
 
DOC
Programas Gambas
RZYMJ
 
DOC
Manual De Gambas
Richard Ochoa
 
DOCX
Programas Gambas
Stalin Rodriguez
 
PPTX
Colegio municipal
lenintoapanta1992
 
Ejemplo En Gambas
eduann
 
Yolygambas
guest286373
 
Yolygambas
rosyp
 
Ejerciciosdeprogramacion
Carmen Bermello Barreiro
 
Proyecto Blob
guest394b4d3
 
Proyecto 2er Parcial
Yuliana9_7
 
Yuliana
Yulissa98564
 
Gambas
guestae07b6
 
Trabajo Para Subir
guest9da3a3
 
Programas Gambas
RZYMJ
 
Programas Gambas
guestdd103d
 
Trabajo Para Subir
guest9da3a3
 
Trabajo Para Subir
guest9da3a3
 
Trabajo Para Subir
guest9da3a3
 
Programas Gambas
RZYMJ
 
Manual De Gambas
Richard Ochoa
 
Programas Gambas
Stalin Rodriguez
 
Colegio municipal
lenintoapanta1992
 

Recently uploaded (20)

PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Doc9.....................................
SofiaCollazos
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
The Future of Artificial Intelligence (AI)
Mukul
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Doc9.....................................
SofiaCollazos
 

Calculadora

  • 1. Calculadora en la programación en GAMBAS PUBLIC CAN AS Integer PUBLIC OPE1 AS Single PUBLIC OPE2 AS Single PUBLIC SUB _new() END PUBLIC SUB Form_Open() END PUBLIC SUB Button17_Click() TextBox1.Clear() END PUBLIC SUB Button18_Click() ME.Close(0) END PUBLIC SUB Button12_Click() TextBox1.Text = TextBox1.Text & "0" END PUBLIC SUB Button13_Click() TextBox1.Text = TextBox1.Text & "." END PUBLIC SUB Button7_Click() TextBox1.Text = TextBox1.Text & "1" END PUBLIC SUB Button8_Click() TextBox1.Text = TextBox1.Text & "2"
  • 2. END PUBLIC SUB Button9_Click() TextBox1.Text = TextBox1.Text & "3" END PUBLIC SUB Button4_Click() TextBox1.Text = TextBox1.Text & "4" END PUBLIC SUB Button5_Click() TextBox1.Text = TextBox1.Text & "5" END PUBLIC SUB Button6_Click() TextBox1.Text = TextBox1.Text & "6" END PUBLIC SUB Button1_Click() TextBox1.Text = TextBox1.Text & "7" END PUBLIC SUB Button2_Click() TextBox1.Text = TextBox1.Text & "8" END PUBLIC SUB Button3_Click() TextBox1.Text = TextBox1.Text & "9" END PUBLIC SUB Button10_Click() CAN = 4 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0
  • 3. ENDIF TextBox1.Clear END PUBLIC SUB Button15_Click() CAN = 1 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Clear END PUBLIC SUB Button14_Click() CAN = 2 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Clear END PUBLIC SUB Button11_Click() CAN = 3 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Clear END PUBLIC SUB Button16_Click() IF TextBox1.Text <> 0 THEN OPE2 = TextBox1.Text ELSE OPE2 = 0
  • 4. ENDIF TextBox1.Text = operacion(OPE1, OPE2, CAN) END PUBLIC FUNCTION operacion(v1 AS Float, v2 AS Float, opera AS Integer) AS Float DIM re AS Float DIM X, Y, Z, X1, Y1, Z1, X2, Y2, Z2, f, i AS Integer DIM XX, MEA AS String SELECT CASE opera CASE 1 re = v1 + v2 CASE 2 re = v1 - v2 CASE 3 re = v1 * v2 CASE 4 re = v1 / v2 CASE 5 re = (v1 * v2) / 100 CASE 6 re = v1 ^ 2 Z2 = 1 CASE 7 re = v1 ^ 3 Z2 = 1 CASE 8 re = v1 ^ v2 Z2 = 1 CASE 9 re = 1 / v1 Z2 = 1 CASE 10 f=1 FOR i = 1 TO v1 f=f*i NEXT re = f Z2 = 1 END SELECT IF Z2 = 1 THEN RETURN re ELSE RETURN Y1 ENDIF END
  • 5. PUBLIC SUB Button19_Click() CAN = 5 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Clear END PUBLIC SUB Button20_Click() CAN = 6 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Text = OPE1 END PUBLIC SUB Button21_Click() 'numero binario DIM valor, x1, x2, i AS Integer DIM 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 Button22_Click()
  • 6. 'Calculo a octal de un número decimal DIM valor, x1, x2, i AS Integer DIM cadena, cadena2 AS String ' IF visor.Text <> 0 THEN 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 Button23_Click() 'Calculo a hexadecimal de un número decimal DIM valor, x1, x2, i AS Integer DIM 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
  • 7. 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() CAN = 7 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Text = OPE1 END PUBLIC SUB Button25_Click() CAN = 8 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Text = OPE1 END PUBLIC SUB Button28_Click() DIM k AS Float k = Rad(TextBox1.Text) TextBox1.Text = Sin(k) END PUBLIC SUB Button29_Click() DIM k AS Float k = Rad(TextBox1.Text) TextBox1.Text = Cos(k) END
  • 8. PUBLIC SUB Button30_Click() DIM k AS Float k = Rad(TextBox1.Text) TextBox1.Text = Tan(k) END PUBLIC SUB Button26_Click() CAN = 9 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Text = OPE2 END PUBLIC SUB Button27_Click() CAN = 10 IF TextBox1.Text <> 0 THEN OPE1 = TextBox1.Text ELSE OPE1 = 0 ENDIF TextBox1.Text = OPE2 END