SlideShare a Scribd company logo
Índices de los botones
Backspace 0 CE 1 C 2 7 3 8 4 9 5
/ 6 sqrt 7 4 8 5 9 6 10 x 11
% 12 1 13 2 14 3 15 - 16 1/x 17
0 18 +/- 19 . 20 + 21 = 22
OptionExplicit
Private mdblResult As Double
Private mdblSavedNumber As Double
Private mstrDot AsString
Private mstrOp AsString
Private mstrDisplay AsString
Private mblnDecEntered AsBoolean
Private mblnOpPending As Boolean
Private mblnNewEquals As Boolean
Private mblnEqualsPressed As Boolean
Private mintCurrKeyIndex As Integer
Private Sub Form_Load()
Top = (Screen.Height - Height) /2
Left= (Screen.Width - Width) /2
End Sub
Private Sub Form_KeyDown(KeyCode AsInteger,ShiftAs Integer)
Dim intIndex AsInteger
Todos los botones se
llaman “cmdCalc”,
solo cambia la
propiedad indice
Etiqueta llamada
lblDisplay
SelectCase KeyCode
Case vbKeyBack: intIndex =0
Case vbKeyDelete: intIndex =1
Case vbKeyEscape: intIndex =2
Case vbKey0,vbKeyNumpad0: intIndex=18
Case vbKey1,vbKeyNumpad1: intIndex=13
Case vbKey2,vbKeyNumpad2: intIndex=14
Case vbKey3,vbKeyNumpad3: intIndex=15
Case vbKey4,vbKeyNumpad4: intIndex=8
Case vbKey5,vbKeyNumpad5: intIndex=9
Case vbKey6,vbKeyNumpad6: intIndex=10
Case vbKey7,vbKeyNumpad7: intIndex=3
Case vbKey8,vbKeyNumpad8: intIndex=4
Case vbKey9,vbKeyNumpad9: intIndex=5
Case vbKeyDecimal: intIndex =20
Case vbKeyAdd: intIndex =21
Case vbKeySubtract: intIndex =16
Case vbKeyMultiply: intIndex =11
Case vbKeyDivide: intIndex =6
Case Else: ExitSub
End Select
cmdCalc(intIndex).SetFocus
cmdCalc_ClickintIndex
End Sub
Private Sub Form_KeyPress(KeyAscii AsInteger)
Dim intIndex AsInteger
SelectCase Chr$(KeyAscii)
Case "S","s": intIndex =7
Case "P","p": intIndex =12
Case "R","r": intIndex =17
Case "X","x": intIndex =11
Case "=": intIndex =22
Case Else: ExitSub
End Select
cmdCalc(intIndex).SetFocus
cmdCalc_ClickintIndex
End Sub
Private Sub cmdCalc_Click(IndexAsInteger)
Dim strPressedKey AsString
mintCurrKeyIndex=Index
If mstrDisplay="ERROR" Then
mstrDisplay=""
End If
strPressedKey=cmdCalc(Index).Caption
SelectCase strPressedKey
Case "0", "1", "2", "3", "4", _
"5", "6", "7", "8", "9"
If mblnOpPendingThen
mstrDisplay=""
mblnOpPending=False
End If
If mblnEqualsPressedThen
mstrDisplay=""
mblnEqualsPressed=False
End If
mstrDisplay=mstrDisplay&strPressedKey
Case "."
If mblnOpPendingThen
mstrDisplay=""
mblnOpPending=False
End If
If mblnEqualsPressedThen
mstrDisplay=""
mblnEqualsPressed=False
End If
If InStr(mstrDisplay,".") >0 Then
Beep
Else
mstrDisplay=mstrDisplay&strPressedKey
End If
Case "+", "-","X","/"
mdblResult=Val(mstrDisplay)
mstrOp= strPressedKey
mblnOpPending=True
mblnDecEntered=False
mblnNewEquals=True
Case "%"
mdblSavedNumber=(Val(mstrDisplay)/100) * mdblResult
mstrDisplay=Format$(mdblSavedNumber)
Case "="
If mblnNewEqualsThen
mdblSavedNumber=Val(mstrDisplay)
mblnNewEquals=False
End If
SelectCase mstrOp
Case "+"
mdblResult=mdblResult+mdblSavedNumber
Case "-"
mdblResult=mdblResult - mdblSavedNumber
Case "X"
mdblResult=mdblResult*mdblSavedNumber
Case "/"
If mdblSavedNumber=0 Then
mstrDisplay="ERROR"
Else
mdblResult=mdblResult/mdblSavedNumber
End If
Case Else
mdblResult=Val(mstrDisplay)
End Select
If mstrDisplay <> "ERROR" Then
mstrDisplay=Format$(mdblResult)
End If
mblnEqualsPressed=True
Case "+/-"
If mstrDisplay<> "" Then
If Left$(mstrDisplay,1) = "-"Then
mstrDisplay= Right$(mstrDisplay,2)
Else
mstrDisplay= "-"& mstrDisplay
End If
End If
Case "Backspace"
If Val(mstrDisplay) <>0 Then
mstrDisplay=Left$(mstrDisplay,Len(mstrDisplay)- 1)
mdblResult=Val(mstrDisplay)
End If
Case "CE"
mstrDisplay=""
Case "C"
mstrDisplay=""
mdblResult=0
mdblSavedNumber=0
Case "1/x"
If Val(mstrDisplay) =0 Then
mstrDisplay="ERROR"
Else
mdblResult=Val(mstrDisplay)
mdblResult=1 / mdblResult
mstrDisplay=Format$(mdblResult)
End If
Case "sqrt"
If Val(mstrDisplay) <0 Then
mstrDisplay="ERROR"
Else
mdblResult=Val(mstrDisplay)
mdblResult=Sqr(mdblResult)
mstrDisplay=Format$(mdblResult)
End If
End Select
If mstrDisplay="" Then
lblDisplay="0."
Else
mstrDot= IIf(InStr(mstrDisplay,".") >0, "", ".")
lblDisplay=mstrDisplay&mstrDot
If Left$(lblDisplay,1) = "0" Then
lblDisplay=Mid$(lblDisplay,2)
EndIf
End If
If lblDisplay="." ThenlblDisplay="0."
End Sub

More Related Content

What's hot

Reservasi hotel
Reservasi hotelReservasi hotel
Reservasi hoteldian pw
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventasDAYANA RETO
 
The Ring programming language version 1.5.1 book - Part 54 of 180
The Ring programming language version 1.5.1 book - Part 54 of 180The Ring programming language version 1.5.1 book - Part 54 of 180
The Ring programming language version 1.5.1 book - Part 54 of 180
Mahmoud Samir Fayed
 
7. copy1
7. copy17. copy1
Ececececuacion de primer grado y
Ececececuacion de primer grado yEcecececuacion de primer grado y
Ececececuacion de primer grado y
Ivan Ramirez Iglesias
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
The Ring programming language version 1.5.1 book - Part 55 of 180
The Ring programming language version 1.5.1 book - Part 55 of 180The Ring programming language version 1.5.1 book - Part 55 of 180
The Ring programming language version 1.5.1 book - Part 55 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 58 of 189
The Ring programming language version 1.6 book - Part 58 of 189The Ring programming language version 1.6 book - Part 58 of 189
The Ring programming language version 1.6 book - Part 58 of 189
Mahmoud Samir Fayed
 
Punto fijo multivariante
Punto fijo multivariantePunto fijo multivariante
Punto fijo multivariante
Remigio Pérez Palomino
 
The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 14 of 210
The Ring programming language version 1.9 book - Part 14 of 210The Ring programming language version 1.9 book - Part 14 of 210
The Ring programming language version 1.9 book - Part 14 of 210
Mahmoud Samir Fayed
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide guiMahmoud Hikmet
 
The Ring programming language version 1.5.3 book - Part 67 of 184
The Ring programming language version 1.5.3 book - Part 67 of 184The Ring programming language version 1.5.3 book - Part 67 of 184
The Ring programming language version 1.5.3 book - Part 67 of 184
Mahmoud Samir Fayed
 
Growing jQuery
Growing jQueryGrowing jQuery
Growing jQuery
gueste8d8bc
 
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Francois Marier
 

What's hot (19)

RandomGuessingGame
RandomGuessingGameRandomGuessingGame
RandomGuessingGame
 
Reservasi hotel
Reservasi hotelReservasi hotel
Reservasi hotel
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventas
 
The Ring programming language version 1.5.1 book - Part 54 of 180
The Ring programming language version 1.5.1 book - Part 54 of 180The Ring programming language version 1.5.1 book - Part 54 of 180
The Ring programming language version 1.5.1 book - Part 54 of 180
 
linieaire regressie
linieaire regressielinieaire regressie
linieaire regressie
 
7. copy1
7. copy17. copy1
7. copy1
 
Ececececuacion de primer grado y
Ececececuacion de primer grado yEcecececuacion de primer grado y
Ececececuacion de primer grado y
 
Yolygambas
YolygambasYolygambas
Yolygambas
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
The Ring programming language version 1.5.1 book - Part 55 of 180
The Ring programming language version 1.5.1 book - Part 55 of 180The Ring programming language version 1.5.1 book - Part 55 of 180
The Ring programming language version 1.5.1 book - Part 55 of 180
 
The Ring programming language version 1.6 book - Part 58 of 189
The Ring programming language version 1.6 book - Part 58 of 189The Ring programming language version 1.6 book - Part 58 of 189
The Ring programming language version 1.6 book - Part 58 of 189
 
Punto fijo multivariante
Punto fijo multivariantePunto fijo multivariante
Punto fijo multivariante
 
The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202
 
The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196
 
The Ring programming language version 1.9 book - Part 14 of 210
The Ring programming language version 1.9 book - Part 14 of 210The Ring programming language version 1.9 book - Part 14 of 210
The Ring programming language version 1.9 book - Part 14 of 210
 
Programming a guide gui
Programming a guide guiProgramming a guide gui
Programming a guide gui
 
The Ring programming language version 1.5.3 book - Part 67 of 184
The Ring programming language version 1.5.3 book - Part 67 of 184The Ring programming language version 1.5.3 book - Part 67 of 184
The Ring programming language version 1.5.3 book - Part 67 of 184
 
Growing jQuery
Growing jQueryGrowing jQuery
Growing jQuery
 
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...Building Persona: federated and privacy-sensitive identity for the Web (Open ...
Building Persona: federated and privacy-sensitive identity for the Web (Open ...
 

Viewers also liked

Pr2 fight club
Pr2 fight club Pr2 fight club
Pr2 fight club
Kieran Jackson
 
LoopMarket-presentacion
LoopMarket-presentacionLoopMarket-presentacion
LoopMarket-presentacion
Loop Market, S.L.
 
Usos energía alternativa
Usos energía alternativaUsos energía alternativa
Usos energía alternativa
Saray López Guti
 
Dutty Love 1221IMT
Dutty Love 1221IMTDutty Love 1221IMT
Dutty Love 1221IMTIsa1221
 
Sistemas
SistemasSistemas
Sistemasjor022
 
4cod 01 nov_amaza.docx
4cod 01 nov_amaza.docx4cod 01 nov_amaza.docx
4cod 01 nov_amaza.docx
Alexa-Maza
 
Drimio na Mídia - 2009
Drimio na Mídia - 2009Drimio na Mídia - 2009
Drimio na Mídia - 2009
Drimio Social Network
 
Ensayo pedagogía
Ensayo pedagogíaEnsayo pedagogía
Ensayo pedagogía
Guadalupe García
 
Powerpoint adaptación
Powerpoint adaptaciónPowerpoint adaptación
Powerpoint adaptación
dopega
 
Thesis preview
Thesis previewThesis preview
Thesis previewKim Yong
 
Estados físicos de los materiales
Estados físicos  de los materialesEstados físicos  de los materiales
Estados físicos de los materiales
colegiolascumbres
 
Night e Day - Doimo Cityline
Night e Day - Doimo CitylineNight e Day - Doimo Cityline
Night e Day - Doimo Cityline
Meka Home Design
 
3 movimientos de_la_tierra_y_sus_efectos_en
3 movimientos de_la_tierra_y_sus_efectos_en3 movimientos de_la_tierra_y_sus_efectos_en
3 movimientos de_la_tierra_y_sus_efectos_enPaula Santis
 
Vrede te midden van strijd!!
Vrede te midden van strijd!!Vrede te midden van strijd!!
Vrede te midden van strijd!!
Noordwolde, Friesland
 
Arte Visual na Adoração
Arte Visual na AdoraçãoArte Visual na Adoração
Arte Visual na Adoraçãoguest447869
 
Закон про техрегламенти
Закон про техрегламентиЗакон про техрегламенти
Закон про техрегламенти
Olga Barna
 

Viewers also liked (20)

Pr2 fight club
Pr2 fight club Pr2 fight club
Pr2 fight club
 
LoopMarket-presentacion
LoopMarket-presentacionLoopMarket-presentacion
LoopMarket-presentacion
 
Usos energía alternativa
Usos energía alternativaUsos energía alternativa
Usos energía alternativa
 
Dutty Love 1221IMT
Dutty Love 1221IMTDutty Love 1221IMT
Dutty Love 1221IMT
 
Sin título 1
Sin título 1Sin título 1
Sin título 1
 
Colegio
ColegioColegio
Colegio
 
Sistemas
SistemasSistemas
Sistemas
 
4cod 01 nov_amaza.docx
4cod 01 nov_amaza.docx4cod 01 nov_amaza.docx
4cod 01 nov_amaza.docx
 
Drimio na Mídia - 2009
Drimio na Mídia - 2009Drimio na Mídia - 2009
Drimio na Mídia - 2009
 
Ensayo pedagogía
Ensayo pedagogíaEnsayo pedagogía
Ensayo pedagogía
 
Powerpoint adaptación
Powerpoint adaptaciónPowerpoint adaptación
Powerpoint adaptación
 
Thesis preview
Thesis previewThesis preview
Thesis preview
 
Estados físicos de los materiales
Estados físicos  de los materialesEstados físicos  de los materiales
Estados físicos de los materiales
 
Night e Day - Doimo Cityline
Night e Day - Doimo CitylineNight e Day - Doimo Cityline
Night e Day - Doimo Cityline
 
3 movimientos de_la_tierra_y_sus_efectos_en
3 movimientos de_la_tierra_y_sus_efectos_en3 movimientos de_la_tierra_y_sus_efectos_en
3 movimientos de_la_tierra_y_sus_efectos_en
 
Fbapres
FbapresFbapres
Fbapres
 
Colegio
ColegioColegio
Colegio
 
Vrede te midden van strijd!!
Vrede te midden van strijd!!Vrede te midden van strijd!!
Vrede te midden van strijd!!
 
Arte Visual na Adoração
Arte Visual na AdoraçãoArte Visual na Adoração
Arte Visual na Adoração
 
Закон про техрегламенти
Закон про техрегламентиЗакон про техрегламенти
Закон про техрегламенти
 

Similar to Calculadora

Const TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docx
Const TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docxConst TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docx
Const TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docx
donnajames55
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
Prof. Dr. K. Adisesha
 
Theater revenue
Theater revenueTheater revenue
Theater revenueSara Hicks
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
Akira Maruoka
 
Aplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnetAplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnet
Diaz Alfahrezy
 
Visual Basic
Visual BasicVisual Basic
Visual Basic
Vj NiroSh
 
Gambas
Gambas Gambas
Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022
Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022
Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022
Andrzej Jóźwiak
 
Vb.net programs
Vb.net programsVb.net programs
Ict project pdf
Ict project pdfIct project pdf
Ict project pdf
Happy Nezza Aranjuez
 
Vb Project ขั้นเทพ
Vb Project ขั้นเทพVb Project ขั้นเทพ
Vb Project ขั้นเทพ
Sinchai Lanon
 
C # (2)
C # (2)C # (2)
Mocks Enabling Test-Driven Design
Mocks Enabling Test-Driven DesignMocks Enabling Test-Driven Design
Mocks Enabling Test-Driven Design
Alexandre Martins
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
Azki Nabidin
 

Similar to Calculadora (20)

Const TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docx
Const TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docxConst TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docx
Const TypeBinary = 1Const ForReading = 1, ForWriting = 2, ForApp.docx
 
Vb file
Vb fileVb file
Vb file
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Theater revenue
Theater revenueTheater revenue
Theater revenue
 
Programas Gambas
Programas GambasProgramas Gambas
Programas Gambas
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
Aplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnetAplikasi rawat-inap-vbnet
Aplikasi rawat-inap-vbnet
 
Visual Basic
Visual BasicVisual Basic
Visual Basic
 
Gambas
Gambas Gambas
Gambas
 
Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022
Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022
Does testability imply good design - Andrzej Jóźwiak - TomTom Dev Day 2022
 
Vb.net programs
Vb.net programsVb.net programs
Vb.net programs
 
Ict project pdf
Ict project pdfIct project pdf
Ict project pdf
 
Vb Project ขั้นเทพ
Vb Project ขั้นเทพVb Project ขั้นเทพ
Vb Project ขั้นเทพ
 
Docimp
DocimpDocimp
Docimp
 
C # (2)
C # (2)C # (2)
C # (2)
 
Mocks Enabling Test-Driven Design
Mocks Enabling Test-Driven DesignMocks Enabling Test-Driven Design
Mocks Enabling Test-Driven Design
 
UtilityCostCalcCode
UtilityCostCalcCodeUtilityCostCalcCode
UtilityCostCalcCode
 
12 gui concepts 1
12 gui concepts 112 gui concepts 1
12 gui concepts 1
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 

Recently uploaded

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

Calculadora

  • 1. Índices de los botones Backspace 0 CE 1 C 2 7 3 8 4 9 5 / 6 sqrt 7 4 8 5 9 6 10 x 11 % 12 1 13 2 14 3 15 - 16 1/x 17 0 18 +/- 19 . 20 + 21 = 22 OptionExplicit Private mdblResult As Double Private mdblSavedNumber As Double Private mstrDot AsString Private mstrOp AsString Private mstrDisplay AsString Private mblnDecEntered AsBoolean Private mblnOpPending As Boolean Private mblnNewEquals As Boolean Private mblnEqualsPressed As Boolean Private mintCurrKeyIndex As Integer Private Sub Form_Load() Top = (Screen.Height - Height) /2 Left= (Screen.Width - Width) /2 End Sub Private Sub Form_KeyDown(KeyCode AsInteger,ShiftAs Integer) Dim intIndex AsInteger Todos los botones se llaman “cmdCalc”, solo cambia la propiedad indice Etiqueta llamada lblDisplay
  • 2. SelectCase KeyCode Case vbKeyBack: intIndex =0 Case vbKeyDelete: intIndex =1 Case vbKeyEscape: intIndex =2 Case vbKey0,vbKeyNumpad0: intIndex=18 Case vbKey1,vbKeyNumpad1: intIndex=13 Case vbKey2,vbKeyNumpad2: intIndex=14 Case vbKey3,vbKeyNumpad3: intIndex=15 Case vbKey4,vbKeyNumpad4: intIndex=8 Case vbKey5,vbKeyNumpad5: intIndex=9 Case vbKey6,vbKeyNumpad6: intIndex=10 Case vbKey7,vbKeyNumpad7: intIndex=3 Case vbKey8,vbKeyNumpad8: intIndex=4 Case vbKey9,vbKeyNumpad9: intIndex=5 Case vbKeyDecimal: intIndex =20 Case vbKeyAdd: intIndex =21 Case vbKeySubtract: intIndex =16 Case vbKeyMultiply: intIndex =11 Case vbKeyDivide: intIndex =6 Case Else: ExitSub End Select cmdCalc(intIndex).SetFocus cmdCalc_ClickintIndex End Sub Private Sub Form_KeyPress(KeyAscii AsInteger) Dim intIndex AsInteger SelectCase Chr$(KeyAscii) Case "S","s": intIndex =7 Case "P","p": intIndex =12 Case "R","r": intIndex =17 Case "X","x": intIndex =11 Case "=": intIndex =22 Case Else: ExitSub End Select cmdCalc(intIndex).SetFocus cmdCalc_ClickintIndex End Sub Private Sub cmdCalc_Click(IndexAsInteger) Dim strPressedKey AsString mintCurrKeyIndex=Index If mstrDisplay="ERROR" Then mstrDisplay=""
  • 3. End If strPressedKey=cmdCalc(Index).Caption SelectCase strPressedKey Case "0", "1", "2", "3", "4", _ "5", "6", "7", "8", "9" If mblnOpPendingThen mstrDisplay="" mblnOpPending=False End If If mblnEqualsPressedThen mstrDisplay="" mblnEqualsPressed=False End If mstrDisplay=mstrDisplay&strPressedKey Case "." If mblnOpPendingThen mstrDisplay="" mblnOpPending=False End If If mblnEqualsPressedThen mstrDisplay="" mblnEqualsPressed=False End If If InStr(mstrDisplay,".") >0 Then Beep Else mstrDisplay=mstrDisplay&strPressedKey End If Case "+", "-","X","/" mdblResult=Val(mstrDisplay) mstrOp= strPressedKey mblnOpPending=True mblnDecEntered=False mblnNewEquals=True Case "%" mdblSavedNumber=(Val(mstrDisplay)/100) * mdblResult mstrDisplay=Format$(mdblSavedNumber) Case "=" If mblnNewEqualsThen mdblSavedNumber=Val(mstrDisplay) mblnNewEquals=False End If SelectCase mstrOp Case "+" mdblResult=mdblResult+mdblSavedNumber
  • 4. Case "-" mdblResult=mdblResult - mdblSavedNumber Case "X" mdblResult=mdblResult*mdblSavedNumber Case "/" If mdblSavedNumber=0 Then mstrDisplay="ERROR" Else mdblResult=mdblResult/mdblSavedNumber End If Case Else mdblResult=Val(mstrDisplay) End Select If mstrDisplay <> "ERROR" Then mstrDisplay=Format$(mdblResult) End If mblnEqualsPressed=True Case "+/-" If mstrDisplay<> "" Then If Left$(mstrDisplay,1) = "-"Then mstrDisplay= Right$(mstrDisplay,2) Else mstrDisplay= "-"& mstrDisplay End If End If Case "Backspace" If Val(mstrDisplay) <>0 Then mstrDisplay=Left$(mstrDisplay,Len(mstrDisplay)- 1) mdblResult=Val(mstrDisplay) End If Case "CE" mstrDisplay="" Case "C" mstrDisplay="" mdblResult=0 mdblSavedNumber=0 Case "1/x" If Val(mstrDisplay) =0 Then mstrDisplay="ERROR" Else mdblResult=Val(mstrDisplay) mdblResult=1 / mdblResult mstrDisplay=Format$(mdblResult) End If Case "sqrt"
  • 5. If Val(mstrDisplay) <0 Then mstrDisplay="ERROR" Else mdblResult=Val(mstrDisplay) mdblResult=Sqr(mdblResult) mstrDisplay=Format$(mdblResult) End If End Select If mstrDisplay="" Then lblDisplay="0." Else mstrDot= IIf(InStr(mstrDisplay,".") >0, "", ".") lblDisplay=mstrDisplay&mstrDot If Left$(lblDisplay,1) = "0" Then lblDisplay=Mid$(lblDisplay,2) EndIf End If If lblDisplay="." ThenlblDisplay="0." End Sub