SlideShare a Scribd company logo
1 of 5
Í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 180Mahmoud Samir Fayed
 
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 180Mahmoud 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 189Mahmoud Samir Fayed
 
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 202Mahmoud 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 196Mahmoud 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 210Mahmoud 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 184Mahmoud Samir Fayed
 
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

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 (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

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 

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