A simple calculator

Level:
Level2

Written By TheVBProgramer.

PROGRAMMING EXERCISE

Calculator

 

Write a VB program that simulates the basic functions and behavior of the Windows calculator program. To study its interface, you can run it by clicking the Start button on the taskbar, then go to Programs, then Accessories. You should at least support the basic functions of addition, subtraction, and multiplication, as well as changing the sign of the number (the +/- key). It's up to you if you want to support the sqrt, %, and 1/x functions. Don't bother with the "M" keys on the left (MC, MR, MS, M+) or the scientific features.

 

 

 

Download solution source code here.

 

If you enjoyed this post, subscribe for updates (it's free)

need help !!

sir ? huhu our teacher assign us the vb project but its hard for us to make it , can we ask some help sir? our concept is about on line shopping with 5-6 forms , its just a simple without the use of database and ADO only very simple form..

thank you and Godbless sir

Simple Fraction calculator

hai! can you give me some idea on making Simple Fraction calculator that calculates answer into simpliest form! plz...

Here's the code for simple calulator

Take a few commands and arrange them in calculator style and start executing the below code with proper command names as specified.

Dim Op1, Op2 As Double
Dim Opr As String

Private Sub Command1_Click()
Text1.Text = Text1.Text + Command1.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
End Sub

Private Sub Command2_Click()
Text1.Text = Text1.Text + Command2.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command3_Click()
Text1.Text = Text1.Text + Command3.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command4_Click()
Text1.Text = Text1.Text + Command4.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command5_Click()
Text1.Text = Text1.Text + Command5.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command6_Click()
Text1.Text = Text1.Text + Command6.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command7_Click()
Text1.Text = Text1.Text + Command7.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command8_Click()
Text1.Text = Text1.Text + Command8.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command9_Click()
Text1.Text = Text1.Text + Command9.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
End Sub

Private Sub Command10_Click()
Text1.Text = Text1.Text + Command10.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
End Sub
Private Sub CommandDot_Click()
If InStr(Text1.Text, ".") Then
Exit Sub
Else
Text1.Text = Text1.Text + "."
End If
End Sub

Private Sub Commandcls_Click()
Text1.Text = ""
End Sub

Private Sub CommandPlus_Click()
Op1 = Val(Text1.Text)
Opr = "+"
Text1.Text = ""
End Sub

Private Sub CommandMinus_Click()
Op1 = Val(Text1.Text)
Opr = "-"
Text1.Text = ""
End Sub

Private Sub CommandMul_Click()
Op1 = Val(Text1.Text)
Opr = "*"
Text1.Text = ""
End Sub

Private Sub CommandDiv_Click()
Op1 = Val(Text1.Text)
Opr = "/"
Text1.Text = ""
End Sub

Private Sub CommandEqu_Click()
Op2 = Val(Text1.Text)
Select Case Opr
Case "+": Text1.Text = Op1 + Op2
Case "*": Text1.Text = Op1 * Op2
Case "-": Text1.Text = Op1 - Op2
Case "/": Text1.Text = Op1 / Op2
End Select
End Sub

Private Sub Commandexit_Click()
End
End Sub

Private Sub Form_Load()
Text1.Text = ""
End Sub

Visual basic 6.0

hai can you pls help me how to create code in a calculator.. just a simple calculator like theres an button like 1,2,3, etc and back space plz ASAP!!!!!!!!!!!!!!!!!!!!!!!!!!

Here's the code for simple calulator

Take a few commands and arrange them in calculator style and start executing the below code with proper command names as specified.

Dim Op1, Op2 As Double
Dim Opr As String

Private Sub Command1_Click()
Text1.Text = Text1.Text + Command1.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
End Sub

Private Sub Command2_Click()
Text1.Text = Text1.Text + Command2.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command3_Click()
Text1.Text = Text1.Text + Command3.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command4_Click()
Text1.Text = Text1.Text + Command4.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command5_Click()
Text1.Text = Text1.Text + Command5.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command6_Click()
Text1.Text = Text1.Text + Command6.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command7_Click()
Text1.Text = Text1.Text + Command7.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command8_Click()
Text1.Text = Text1.Text + Command8.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If

End Sub

Private Sub Command9_Click()
Text1.Text = Text1.Text + Command9.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
End Sub

Private Sub Command10_Click()
Text1.Text = Text1.Text + Command10.Caption
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
End Sub
Private Sub CommandDot_Click()
If InStr(Text1.Text, ".") Then
Exit Sub
Else
Text1.Text = Text1.Text + "."
End If
End Sub

Private Sub Commandcls_Click()
Text1.Text = ""
End Sub

Private Sub CommandPlus_Click()
Op1 = Val(Text1.Text)
Opr = "+"
Text1.Text = ""
End Sub

Private Sub CommandMinus_Click()
Op1 = Val(Text1.Text)
Opr = "-"
Text1.Text = ""
End Sub

Private Sub CommandMul_Click()
Op1 = Val(Text1.Text)
Opr = "*"
Text1.Text = ""
End Sub

Private Sub CommandDiv_Click()
Op1 = Val(Text1.Text)
Opr = "/"
Text1.Text = ""
End Sub

Private Sub CommandEqu_Click()
Op2 = Val(Text1.Text)
Select Case Opr
Case "+": Text1.Text = Op1 + Op2
Case "*": Text1.Text = Op1 * Op2
Case "-": Text1.Text = Op1 - Op2
Case "/": Text1.Text = Op1 / Op2
End Select
End Sub

Private Sub Commandexit_Click()
End
End Sub

Private Sub Form_Load()
Text1.Text = ""
End Sub

when am

when am adding/multiplying/subtracting multiple numbers ,the input will take last two digits and display the output.i need multiple values display.can u tel me that program code.

vb programming

hi,can i use vb6 to create drop down menu which hold file,edit,help etc? If yes plese send me GUI and code for it. Please help...
E_mali me
nuhuaadamu@nokiamail.com
i'm waiting...

Totally awesome

Although, I don't really wanna spend my time on VB6 because I prefer VB.net but for the fact that this code helped solve my lecturer's ish, I'm so grateful to you dude!

Scientific Calculator

I have successfully done the coding expexted LOC (Lines Of Code) nearly 1500.
time taken=7 days.....................
trial version at Rs. 500/- for 2 months
Anyone interested can get it by paying Rs.1000/- only......................

simple calculator

question about the keypresse event. first of all before anything, thank you for the codes. we really appreciate it.
getting back on the keypress event i have notice that
when i press the 2 + 2 then the enter on the computer keypads it answer 22. why is that?
thank you

2+2 =22

This is because while entering the code for adding something we have to put val. for eg: text3= val(text1)+val(text2).
If we dont use val in front of it then the processor wil think that it has to join the values together.

simple calculator in visual basic

hey plz help me !!!!!!
i wanna make a simple calculator using vb.net

Option Explicit Private

Option Explicit

Private mdblResult As Double
Private mdblSavedNumber As Double
Private mstrDot As String
Private mstrOp As String
Private mstrDisplay As String
Private mblnDecEntered As Boolean
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 As Integer, Shift As Integer)

Dim intIndex As Integer

Select Case 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: Exit Sub
End Select

cmdCalc(intIndex).SetFocus
cmdCalc_Click intIndex

End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)

Dim intIndex As Integer

Select Case 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: Exit Sub
End Select

cmdCalc(intIndex).SetFocus
cmdCalc_Click intIndex

End Sub

Private Sub cmdCalc_Click(Index As Integer)

Dim strPressedKey As String

mintCurrKeyIndex = Index

If mstrDisplay = "ERROR" Then
mstrDisplay = ""
End If

strPressedKey = cmdCalc(Index).Caption

Select Case strPressedKey
Case "0", "1", "2", "3", "4", _
"5", "6", "7", "8", "9"
If mblnOpPending Then
mstrDisplay = ""
mblnOpPending = False
End If
If mblnEqualsPressed Then
mstrDisplay = ""
mblnEqualsPressed = False
End If
mstrDisplay = mstrDisplay & strPressedKey
Case "."
If mblnOpPending Then
mstrDisplay = ""
mblnOpPending = False
End If
If mblnEqualsPressed Then
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 mblnNewEquals Then
mdblSavedNumber = Val(mstrDisplay)
mblnNewEquals = False
End If
Select Case 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)
End If
End If

If lblDisplay = "." Then lblDisplay = "0."

End Sub

Private Sub lblDisplay_Click()

End Sub

laiza_noquil@yahoo.com

are u willing to pay?if ever i will teach you how to make a simple calculator?
Can i apply a call center agent?I'am fluent in english and i can assure you that i will be a good employee...

4 u !

I've also developed my simple calculator bt nt at all like this strong written code. So its a boon in helping while willing 4 developing more ahead. Infct wht u told dat u r fluent in English !? Where r u living ???

Need programmer that will

Need programmer that will help me create a database that will graph an input.
email me willing to pay. Need this project within next week

laiza_noquil@yahoo.com

can any one tell me coding

can any one tell me coding for general ledger and trial balance for visual basic? my email is ahson-cena@hotmail.com. mail me please.

Codes Of Your Calculator

Good day,

I would like to request the codes of your calculator the one displayed here. I can't download the codes.. pls tell me what to do. I need to study the process of creating a calculator.

Kindly help me to create a calculator using option explicit.

Thank you very much.

source code for calculator

source code for calculator

Please click the Download

Please click the Download solution source code here link above. That will download the VB code for this calculator sample.

Tnx for dis wonderful work

Tnx for dis wonderful work you'v been doing here......pls can i hv the user interface of this simple calculator...pls

data needs to saved in ms-access

Hi,

I would like to know how to write a programne that i need to enter the details like name, emp id, dob, city. Which it has to save in ms-access plz tell me how to create the programe

Pls help me...

Tis is my assignment question..since I'm not good in VB,pls me..i have to submit on 29 June 2012..pls do help me...pls...

design simple calculator that takes two numbers as input and perform selected operation using option button.The form form must contain :

- two text boxes for inputting the numbers
-four option buttons for addition, subtraction,multiplication and division
-one command button for calculate,one command button for clear and one for exit.
-one label to show the results

The programs must make decisions using an If...Then statement, based on the value button of the Option button

Tis is my assignment

Tis is my assignment question..since I'm not good in VB,pls me..i have to submit on 28 June 2012..pls do help me...pls...

design simple calculator that takes two numbers as input and perform selected operation using option button.The form form must contain :

- two text boxes for inputting the numbers
-four option buttons for addition, subtraction,multiplication and division
-one command button for calculate,one command button for clear and one for exit.
-one label to show the results

The programs must make decisions using an If...Then statement, based on the value button of the Option button

vb

hai sir..i'm doing my Visual Basic 6.0 assignment..since i'm not good in VB,can sir help me?? 1 need to develop one mini project that implements this method:
1) variable
2)constant variable
3)calculation
4)formatting data
5)If..Else statement
6)Select Case
7)Validation
8)Clearing method
9)Menu

Pls help me sir..i need to submit on 26 june..it will grateful if u help me..pls help me...

hai sir..i'm doing my Visual

hai sir..i'm doing my Visual Basic 6.0 assignment..since i'm not good in VB,can sir help me?? 1 need to develop one mini project that implements this method:
1) variable
2)constant variable
3)calculation
4)formatting data
5)If..Else statement
6)Select Case
7)Validation
8)Clearing method
9)Menu

Pls help me sir..i need to submit on 26 june..it will grateful if u help me..pls help me...

hai sir..i'm doing my Visual

hai sir..i'm doing my Visual Basic 6.0 assignment..since i'm not good in VB,can sir help me?? 1 need to develop one mini project that implements this method:
1) variable
2)constant variable
3)calculation
4)formatting data
5)If..Else statement
6)Select Case
7)Validation
8)Clearing method
9)Menu

Pls help me sir..i need to submit on 26 june..it will grateful if u help me..pls help me...

pls i need a source code for

pls i need a source code for complete scientific calculator ........... pls anyone help me.... this is my final year mini project...so pls help me.help me ............

pls i need a source code for

pls i need a source code for complete scientific calculator ........... pls anyone help me.... this is my final year mini project...so pls help me.help me ............

Simple calculater

1-make a label in the form screen .
2-click at the label software .
3-tipe these codes.
Private sub form_load ()
Dim num1 as integer
Dim num2 as integer
Dim sum as integer
Num1 = val (inputbox("enter first number","num1"))
Num2 = val (inputbox("enter second number ","num2"))
Sum = num1+num2
Label1.caption=label1.caption$str(sum)
End sub
4-do the programe.

Masoud_o@yahoo.com
+962776440555
At Amman - jordan

i need ur help between now and 9am tomorrow

design a simple calculator that contain the following operators addition, subtration, multiplication, division, integer division and modules. am submiting it tomoro by 11am. God bless u

PLEASE Help me !!

please help me to finish this calc.
this calc.'s work, but when i do this < 1 + 1 * 2 > or i should say when using other operations it stops working. here's my code:
Public Class Form1
Dim num1, num2 As Integer
Dim opr As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
lbl1.Text = lbl1.Text & "0"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
lbl1.Text = lbl1.Text & "1"
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
lbl1.Text = lbl1.Text & "2"
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
lbl1.Text = lbl1.Text & "3"
End Sub

Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
lbl1.Text = lbl1.Text & "4"
End Sub

Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
lbl1.Text = lbl1.Text & "5"
End Sub

Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
lbl1.Text = lbl1.Text & "6"
End Sub

Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
lbl1.Text = lbl1.Text & "7"
End Sub

Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
lbl1.Text = lbl1.Text & "8"
End Sub

Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
lbl1.Text = lbl1.Text & "9"
End Sub

Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
lbl1.Text = ""
End Sub

Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
num1 = Val(lbl1.Text)
opr = "+"
lbl1.Text = ""
End Sub

Private Sub btnsubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsubtract.Click
num1 = Val(lbl1.Text)
opr = "-"
lbl1.Text = ""
End Sub

Private Sub btnmultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmultiply.Click
num1 = Val(lbl1.Text)
opr = "*"
lbl1.Text = ""
End Sub

Private Sub btndivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndivide.Click
num1 = Val(lbl1.Text)
opr = "/"
lbl1.Text = ""
End Sub

Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnequals.Click
num2 = Val(lbl1.Text)
Select Case opr
Case "+" : lbl1.Text = num1 + num2
Case "-" : lbl1.Text = num1 - num2
Case "*" : lbl1.Text = num1 * num2
Case "/" : lbl1.Text = num1 / num2
End Select

End Sub

Private Sub lbl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl1.Click
lbl1.Text = ""
End Sub
End Class
________________________________________________________________
tnx ^^

very good new code

i made a calc by this code
Dim x, y, z
x = Val(TextBox1.Text)
y = Val(TextBox2.Text)
z = x + y
TextBox3.Text = z
.
,
,
,
try it note use any other sign *-/+^ to change the function of it
:D

Tip: The buttons + - * / AND

Tip:

The buttons + - * / AND =
sould be the almost the SAME

Hello, I am pharmacy student

Hello,
I am pharmacy student and learning visual basic for one project. so i dont know even "V" of visual basic. i did coding for plus, minus, divide and multiply and square but i have some more functions to do like square root, M+ ,M-, MRC. I dont know how to code for that so if anyone can send me a code for these things.

Thanks

ano ba e-mail ad mo?

ano ba e-mail ad mo?

my help

i will e-mail you the complete codes for scientific calculator
try to understand the codes and its syntax.

Hy

Well sorry bt i myself m in search of those functions...if u get it fm anywhere plz tell me!!!

File org....

Private Sub Form_Load()
InputBox "Enter your Name:"
InputBox "Enter first number:"
InputBox "Enter second number:"

Let N1 = 20
Let N2 = 10
Let Sum = N1 + N2
Let T2 = N1 - N2
Let T3 = N1 * N2
Let T4 = N1 / N2

Let TADD = N1 + N2
Let TSUB = N1 - N2
Let TMUL = N1 * N2
Let TDIV = N1 / N2

Print "using Math"
Print "___________________"
Print " Answer in Addition is:"; TADD
Print " Answer in Subtraction is:"; TSUB
Print " Answer in Multiplication is:"; TMUL
Print " Answer in Division is:"; TDIV

End Sub

Help me plz for coding thiz!!!!!!

Visual basics - calculator

please help me, i have to make a simple calculator interface with digits that can perform functions like add and subtract integers, with plus, minus, clear buttons, an equal sign and a display. Pls help me i dont get programming.

Dim strOptr As String Dim

Dim strOptr As String
Dim num1 As Double
Dim isNum, isDec As Boolean

Private Sub initDisplay()
display.Text = "0."
num1 = 0
strOptr = ""
isNum = False
isDec = False
End Sub

Private Sub answr_Click()
Dim strNum As String
Dim strdisplay As String
strdisplay = display.Text

Select Case (strOptr)
Case "+"
num1 = CDbl(num1) + CDbl(strdisplay)
Case "-"
num1 = CDbl(num1) - CDbl(strdisplay)
Case "x"
num1 = CDbl(num1) * CDbl(strdisplay)
Case "/"
num1 = CDbl(num1) / CDbl(strdisplay)
End Select
strNum = CStr(num1)
If (InStr(strNum, ".") = 0) Then
display.Text = CStr(num1) + "."
Else
display.Text = CStr(num1)
End If
End Sub
Private Sub centertoscreen()
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
End Sub

Private Sub clear_Click()
Call initDisplay
End Sub

Private Sub decimalpt_Click()
isDec = True
End Sub

Private Sub Form_Load()
Call centertoscreen
Call initDisplay
End Sub

Private Sub num_Click(Index As Integer)
Dim strvalid As String
strvalid = "0123456789"

If (InStr(strvalid, num(Index).Caption) > 0) Then
Call appendnum(num(Index).Caption)
End If
End Sub

Private Sub operator_Click(Index As Integer)
Dim strvalid As String
strvalid = "+-x/"
If (InStr(strvalid, operator(Index).Caption) > 0) Then
strOptr = operator(Index).Caption
Call SetNumber
End If
End Sub

Private Sub appendnum(x As String)
Dim strdisplay As String
strdisplay = display.Text
If (InStr(strdisplay, ".") = Len(strdisplay)) Then
strdisplay = Left(strdisplay, Len(strdisplay) - 1)
End If
If (strdisplay = "0" Or isNum = False) Then
If (isDec = True) Then
If (strdisplay = 0) Then
display.Text = strdisplay + "." + x
Else
display.Text = "0." + x
End If
Else
display.Text = x + "."
End If
Else
If (InStr(strdisplay, ".") = 0) Then
If (isDec = True) Then
display.Text = strdisplay + "." + x
Else
display.Text = strdisplay + x + "."
End If
Else
display.Text = strdisplay + x
End If
End If
isNum = True
isDec = False
End Sub

Private Sub SetNumber()
Dim strdisplay As String
strdisplay = display.Text

num1 = CDbl(strdisplay)
isNum = False
End Sub

Private Sub plusminus_Click()
Dim strdisplay As String
strdisplay = display.Text
If (InStr(strdisplay, "-") = 0) Then
strdisplay = "-" + strdisplay
Else
strdisplay = Right(strdisplay, Len(strdisplay) - 1)
End If
display.Text = strdisplay
End Sub

....

ask lang po hahahha kalimutan ko na kc VB e bakit pag 1+1 nag i equal sya sa 11?

lagyan m nang val para ma

lagyan m nang val para ma analyze nya ung value

sample text1.text = val (tetx2.text) + (text3.text)

bakit?

kc hindi mo dineclare na value ung ginamit mo..for example text1.text=text2.text + text3.text (imagine pag pinarun natin to sa text2 ang ininput mo ay 1 at sa text3 ininput mo din ay 1 ang answer na lalabas ay 11 kc hindi value pagkakabasa nito TEXT lan so ang proper code nito ay text1.text=val(text2.text) + val(text3.text)...hope nakatulong to :)

help me for percentage calculation!

papano po ang codes sa percentage kapag ung button mo eh for discounts?? 5% hanggang 25% lang po...please help ....

Computer sccience

Plz send me code for back space button in calculator

c# backspace code

string s = textBox1.Text;
int i = s.Length;
textBox1.Text = s.Substring(0, i - 1);

mga walangya kayo!

simple simpleng bagay! buy a calculator!

ulol

,,,bliw kb,,,la nga pera ee..,,pero mei png net aq..,,

tanga ka ang yabang mo.

bobo ka, ang yabang mo. baka nga hirap ka pa mag code ng simple na calculator e. tsss

ahm!- hope that this codes is

ahm!-
hope that this codes is effective because i'm not perfectly good in program!
pls help me

vb

ahm!
i'll try dis codes!!
because this is my assignment!
thnk you

help, annoying code !!!!!!!!

my calculator will only allow me to enter one intger at a time?!
and also, my minus numbers are going funny, they are minusing, but giving the wrong answer...
help please :')

vb

hey if u r printing the result in a label then write
label.caption=label.caption+command.item(index).caption

this may be wrong so first make sure that this is correct

E2 VB 8

Public Class Form1
'Holds which operation to perform.
Dim operand1 As Decimal
'Holds which operation to perform.
Dim operand2 As Decimal
Dim ope As Char
Dim isOpe As Boolean
'Holds whether the remaining values in the
'textbox is the calculated values or not.
Dim calculated As Boolean = False
Dim memoryRecall As Decimal
Dim memorysave As Decimal

Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click, Button3.Click, Button2.Click, Button18.Click, Button17.Click, Button16.Click, Button12.Click, Button11.Click, Button10.Click, Button1.Click
If isOpe = True Then
txtDisplay.Clear()
isOpe = False
End If
txtDisplay.Text &= CType(sender, Button).Text
End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click, Button7.Click, Button6.Click, Button15.Click, Button14.Click, Button19.Click
isOpe = True
ope = CType(sender, Button).Text
operand1 = txtDisplay.Text

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
'First make sure memory contains something to calculate.
If txtDisplay.Text = Nothing OrElse txtDisplay.Text = "" Then Exit Sub
operand2 = txtDisplay.Text

If ope = "+" Then
'adding first operand to 2nd operand.
txtDisplay.Text = CDec(operand1) + CDec(operand2)
End If
If ope = "-" Then
txtDisplay.Text = CDec(operand1) - CDec(operand2)
End If
If ope = "*" Then
txtDisplay.Text = CDec(operand1) * CDec(operand2)
End If
If ope = "/" Then
txtDisplay.Text = CDec(operand1) / CDec(operand2)
End If
'hmm. my % value is fixed at 100%, haha
If ope = "%" Then
txtDisplay.Text = CDec(txtDisplay.Text) / CDec(100) * operand1
End If
'getting the square root of the nubmers
If ope = "√" Then
txtDisplay.Text = Math.Sqrt(operand2)
End If

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
txtDisplay.Clear()
End Sub

Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
txtDisplay = Nothing

End Sub

Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button28.Click
txtDisplay.Paste()

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If txtDisplay.Text.Contains(".") Then
Exit Sub
Else
txtDisplay.AppendText(".")
End If
End Sub

Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button26.Click

End Sub

Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
'These codes will convert a Signed number to a Unsigned number and vice-versa.
Dim txtValue As Decimal

'txtValue decimal variable created above.
If Decimal.TryParse(txtDisplay.Text, txtValue) Then
'If "-1" is returned then its a negative number. If it returns 1, then its a positive
'number
If Math.Sign(txtValue) = "-1" Then
' to convert a value to a positive number :)
txtDisplay.Text = Math.Abs(txtValue)
'math.absolute value.= getting the real numbers in short
'only positive integers will be accepted
Else
' to convert a value to a negative number :)
txtDisplay.Text = -txtDisplay.Text

End If

End If
End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
'decimal tryparse , to overload but specify the invalid value.
If Decimal.TryParse(txtDisplay.Text, vbNullString) Then

txtDisplay.Text = 1 / (CDec(txtDisplay.Text))
'Update to True since you should have just calculated the values.
calculated = True

End If
End Sub

Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button27.Click
txtDisplay.Text = Nothing

End Sub

Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button25.Click

End Sub

Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button24.Click

End Sub

Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button22.Click
'Keep removing digits one at a time until there are no more left.
'
If txtDisplay.TextLength = 0 Then

Exit Sub

Else
'removing digits by 1 starting from right.
txtDisplay.Text = txtDisplay.Text.Remove(txtDisplay.TextLength - 1)

End If
End Sub
End Class

thanks

i like your calculator coding very much and this is mind blowing. nice work. i shall pray for you" ,may allah bless you with success at every step of life.

how to do this

Hello, i'd create a calculator which can be click to like this:
1. if click each cmdNumber (9 ). Ex. 9 will show in result textbox
2. if click each cmdMath ( + ). Ex. 9+ will show in the result textbox
3. if click each cmdNumber (5). Ex 9+5 will show in the result textbox
4. if click each cmdEquilt( =) . Ex. the result textbox is 14.
I'd know how to coding this project as MS calculator ?

ahmmm...

ok,, thanks d2... :) hehe

help me for coding of sec,cosec,+or-(sign)

hi!plz any1 giv codes 4 d following:
sec,cosec,cot,+or-(sign),and other scientific codes like cm->m,inches->feet,sinh,cosh,
my email:santhu.kumar982@yahoo.com

Need Program in VB 6.0

I want Program for menu editor holding file ,edit and help menu

TSK

my e-mail is bourgeiosue@yahoo.com thank you.!

TSK

Can you please e-mail me a code of this =) thank you.

la lang

can you send me a code of scientific calculator.. plzz help me .
this is me email add crf_jerks@yahoo.com of firelovemutch@yahoo.com

calculator

hi its me i want to make a simple calculator program but dont know why...??? pls help me
i want to make a calculator

This is my code...but some is not functioning pls fixed this....

Option Explicit
Dim Op1 As Double, Op2 As Double
Dim Opr As String
Dim cleardisplay As Boolean

Private Sub Cmd0_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd0.Caption
End Sub

Private Sub Cmd1_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd1.Caption
End Sub

Private Sub Cmd2_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd2.Caption
End Sub

Private Sub Cmd3_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd3.Caption
End Sub

Private Sub Cmd4_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd4.Caption
End Sub

Private Sub Cmd5_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd5.Caption
End Sub

Private Sub Cmd6_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd6.Caption
End Sub

Private Sub Cmd7_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd7.Caption
End Sub

Private Sub Cmd8_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd8.Caption
End Sub

Private Sub Cmd9_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + cmd9.Caption
End Sub

Private Sub cmdcls_Click()
Text1.Text = ""
End Sub

Private Sub Cmddiv_Click()
Op1 = Val(Text1.Text)
Opr = "/"
Text1.Text = ""
End Sub

Private Sub CmdEqu_Click()
Op2 = Val(Text1.Text)
Select Case Opr
Case "+": Text1.Text = Op1 + Op1
Case "*": Text1.Text = Op1 * Op2
Case "-": Text1.Text = Op1 - Op2
Case "/": Text1.Text = Op1 / Op2
End Select
End Sub

Private Sub CmdMinus_Click()
Op1 = Val(Text1.Text)
Opr = "-"
Text1.Text = ""
End Sub

Private Sub Cmdmul_Click()
Op1 = Val(Text1.Text)
Opr = "*"
Text1.Text = ""
End Sub

Private Sub cmdexit_Click()
End
End Sub

Private Sub CmdPlus_Click()
Op1 = Val(Text1.Text)
Opr = "+"
Text1.Text = ""
End Sub

Private Sub Form_Load()
Text1.Text = ""
End Sub

reply plz...

Qustion

can i perform multiple operations like 20+30-10+20 using this?how?

root

i cant get the code of root key. others are perfect .please give it.i want it.........

Hey first note one thing ,

Hey first note one thing , root is x to the power of 1/2, it is just the opposite of x squared.

So the code is:

Private sub cmdSqrt_click()
Text1.text=val(Text1.text)^1/2
End Sub

Hope this code works fine for you , as it does for me..

Rgds,
Sriram.r

magicp ka kya ptanong-tnong k

magicp ka kya ptanong-tnong k pa? anong akala mo alm nmin yan bliw d q nga yn pnagaaraln ei...abno

we dont know also the answer

we dont know also the answer ok..haha

its needed

when i'd try to calculate 1+1, i've got 2 as answer.But when i press 1+1+1 the result is 2.how can i make it as 3 ?? even 1+2+3+4 i cant get the right answer. what do you think the right code here ??

thank you. :)) i'll wait you're response.

Buddy consider an example

Buddy
consider an example where you have to add 1+2+3+4

Now here i declare two variables obj1 and obj22
you know your calculator
when you press any number keys the keys get displayed in the textbox ............. rite
now we have to make something like this "variable=variable+1" so whenever you enter any value it should be stored in the variable(i.e.obj)
so your code should be something like this
obj1=obj1+val(Display.text)

as a result the "val" will ensure that the number in the textbox is kept as a number in short we are telling our programme that to remember what is in the variable
thats it
declare 2nd variable and then add them you can add multiple numbers now

Calculator at VB6

Have a problem, i have 4 TextBox 1 for Num1, 1 for Num2, 1 for the Arithmetic Sign and last for The Answer.
What code should I use to make the other digit will be place on the Num2 TextBox. Bacause everytime I click the cmd1 always place on the Num1 TextBox only..Please help!!!

Reply

when we insert the text box on the user form, then the property of text box in name field is "TextBox1".You can change that property in name field (text1), then in this code you can use "text1.text"

ERROR

it's a good calculator...The default windows calculator is very small....So i tried to use this calculator ; re sized all buttons and text box .... problem i found in this calculator is that when i calculate 1+1, i'll get 2 as answer.But when i press 1+1+1 the result is 2.Another problem is that if i pressed ENTER button after any calculation , i don't get the result of that function.which means key press event (Case "=": intIndex = 22 )is not working . Please can some one fix it.

vb6 great!!

what a great job.. i help a lot thank you!!

i need it now.or tomorrow.

i need it now.or tomorrow. please in vb6. this is my number.09487372842 ill wait for it. yhank you so much.
^_^

help me please. if you don't

help me please. if you don't mind. what is the code of simple calculator. in equals? using the switch syntax?
3+3= ?
the codes in equals?
thank you. more power.

spl

PLEASE I NEED IT AS SOON AS POSSIBLE!!

can somebody help me??
can somebody gave me a simple code of simple calculator?
using java??
this is urgent.. PLEASE HELP!!

lol

"can somebody gave you a simple code of simple calculator using java?",, whaAaat??? your requesting then its past tense..confusing..^_^

lol

"can somebody gave you a simple code of simple calculator using java?",, whaAaat??? your requesting then its past tense..confusing..^_^

What will be the coding for

What will be the coding for calculator in such a way if there is only 1 text box nd when i enter 1st value then "+" or any arithmatic opertator nd after that "2nd value" but as I'll enter 2nd value then text field shoul be immediately cleared......reply as soon as possible

sir help me please!!

mam and sir can u help me....what is the code for percentage..please because i have a project....help me please

Im stuck :/

Im stuck :/

I would like to make a

I would like to make a calculator for a formula. But i didn't know how to include the Sine function inside. Can you teach me how to do Sine calculation?..
Formula is A = (d/sin c * sin e) + f
Each of the d,c,e,f will have input area there. Now just left the sine.. HELP PLZ!...

Help

sir i need ur help 4 coding a simple calculator so pls help me

scnvsnvl

Option Explicit

Private mdblResult As Double
Private mdblSavedNumber As Double
Private mstrDot As String
Private mstrOp As String
Private mstrDisplay As String
Private mblnDecEntered As Boolean
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 As Integer, Shift As Integer)

Dim intIndex As Integer

Select Case 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: Exit Sub
End Select

cmdCalc(intIndex).SetFocus
cmdCalc_Click intIndex

End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)

Dim intIndex As Integer

Select Case 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: Exit Sub
End Select

cmdCalc(intIndex).SetFocus
cmdCalc_Click intIndex

End Sub

Private Sub cmdCalc_Click(Index As Integer)

Dim strPressedKey As String

mintCurrKeyIndex = Index

If mstrDisplay = "ERROR" Then
mstrDisplay = ""
End If

strPressedKey = cmdCalc(Index).Caption

Select Case strPressedKey
Case "0", "1", "2", "3", "4", _
"5", "6", "7", "8", "9"
If mblnOpPending Then
mstrDisplay = ""
mblnOpPending = False
End If
If mblnEqualsPressed Then
mstrDisplay = ""
mblnEqualsPressed = False
End If
mstrDisplay = mstrDisplay & strPressedKey
Case "."
If mblnOpPending Then
mstrDisplay = ""
mblnOpPending = False
End If
If mblnEqualsPressed Then
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 mblnNewEquals Then
mdblSavedNumber = Val(mstrDisplay)
mblnNewEquals = False
End If
Select Case 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)
End If
End If

If lblDisplay = "." Then lblDisplay = "0."

End Sub

what si this?

what si this?

calculator

hello sir its my first attempt to vb . And i m programming in vb to the make the simple calculator (+,-,*,and /) .So will u give me a simple coading to make a calculator.

HELP PLEASE.

i was wondering what the codes are for a SQRT, percentage and 1/x button... please and thank you :D

vb 6.0

can you give all codings of calculator!
tnx and more power

scientific calculator

helo would u pls send me the coding of a scientific calculator including the following buttons: cos cos-1 tan tan-1 log

VB sin, cos, tan

sin(text1.text)
cos(text1.text)
tan(text1.text)

Sin Cos Tan

guys how to make sine , cosine and tan of an angel I want to put it's number in the text box and give me sin or cos or tan in the label what codes should I write

Sin or cos ...etc

hello!for sin or cos etc do it-
text1.text=math.sin(val(text1.text))
similarly u get other values wen u type "MATH."

hai

can send me the code for simple visual basic calculator ..:))
i really need it now ... tsk^..^..^..^..^..^..^..^

calculator problem:i want to design calculator with 3 inputs

hey,guys..i want to create a simple calculator that has a three input or text box. It contains MDAS operation,but i don't know the code..Please anyone can help me here....

code for backspace button

code for backspace button pls.. thanks a lot.. more power...:)

This is a simple calculator coding. by Gursewak singh

Option Explicit
Dim Op1 As Double, Op2 As Double
Dim Opr As String
Dim cleardisplay As Boolean

Private Sub Cmd0_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd0.Caption
End Sub

Private Sub Cmd1_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd1.Caption
End Sub

Private Sub Cmd2_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd2.Caption
End Sub

Private Sub Cmd3_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd3.Caption
End Sub

Private Sub Cmd4_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd4.Caption
End Sub

Private Sub Cmd5_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd5.Caption
End Sub

Private Sub Cmd6_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd6.Caption
End Sub

Private Sub Cmd7_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd7.Caption
End Sub

Private Sub Cmd8_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd8.Caption
End Sub

Private Sub Cmd9_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd9.Caption
End Sub

Private Sub CmdC_Click()
Text1.Text = ""
End Sub

Private Sub Cmddiv_Click()
Op1 = Val(Text1.Text)
Opr = "/"
Text1.Text = ""
End Sub

Private Sub CmdDot_Click()
If InStr(Text1.Text, ".") Then
Exit Sub
Else
Text1.Text = Text1.Text + "."
End If
End Sub

Private Sub CmdEqu_Click()
Op2 = Val(Text1.Text)
Select Case Opr
Case "+": Text1.Text = Op1 + Op2
Case "*": Text1.Text = Op1 * Op2
Case "-": Text1.Text = Op1 - Op2
Case "/": Text1.Text = Op1 / Op2
End Select
End Sub

Private Sub CmdMinus_Click()
Op1 = Val(Text1.Text)
Opr = "-"
Text1.Text = ""
End Sub

Private Sub Cmdmul_Click()
Op1 = Val(Text1.Text)
Opr = "*"
Text1.Text = ""
End Sub

Private Sub CmdOFF_Click()
End
End Sub

Private Sub CmdPlus_Click()
Op1 = Val(Text1.Text)
Opr = "+"
Text1.Text = ""
End Sub

Private Sub Form_Load()
Text1.Text = ""
End Sub

problem occured while printing the result

hello sir, i used ur code but it i not printing the reult

nice work! its functioning

nice work! its functioning

elow sir!!!.have u stated

elow sir!!!.have u stated above the backspace button for the silmple calculator code??.I cant find it.thanks a lot.and have a great day!!

Help

Help po please.

Write a program that accepts a postfix notation keyed into a text field when a button labeled “push” is pressed. A button labeled “pop” causes the item to be popped and displayed in the text field.

Example:

enter mo ka ng isang postfix notation.

9 7 + 5 3 - /

tapos, click mo yung button na PUSH, add niya sa stack.
tapos, kapag click mo yung POP, lalabas siya pero this this INFIX na

(9 + 7) / (5 - 3)

sana po makahelp kayo. ;[

I need code for -/+ button

I'm trying to make a negative/positive button in my calculator. I need to input a negative integer but I don't know hows it is. HELP me plss =))

this is code for +/- bttn .

Private Sub PlusMinus_Click()
Display.Caption = -Val(Display.Caption)
End Sub

set property ----- Caption -> +/-
name -> PlusMinus

Try Private Sub

Try
Private Sub BtnSwitch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSwitch.Click
If txtDisplay.Text > 0 Then
txtDisplay.Text = -+txtDisplay.Text
Else
txtDisplay.Text = -(CInt(txtDisplay.Text))
End If
End Sub

vb help

what is the code for memory (MMC) and point (.) in simple calculator please help me ??

pls halp me

panu po ung code ng simple calculator na operation nia ay kunwari ganito
5-8+9=12

vb6

can you help me with the codes of ce in scientific calculator

scientific calculator

plsss help me in making my project in vb6
i'm now creating an scientific calculator
can you send me codes for the scientific calculator
just message it to me at facebook my e-mail is joecon_19951@yahoo.com
thnx in advance ^^

Please help me to complete

Please help me to complete my calculator....what is the code of, sqrt, %,1/x,MC,Mr,MS,M+, Backspace,C CE.. thank you.., I hope you can helpme.

contact me at +919478418880

contact me at +919478418880

---this is such a great help

---this is such a great help for my project..thank you so much^^
--JeMaeA

GODBLESS

GODBLESS

I have a project on visual

I have a project on visual basic 6.0. To create a calculator showing the 4 basic operations. Its a simple calculator.
Kindly help me plsssss
Regards
Anonymous

Hello sir plz help me i

Hello sir plz help me i want the source code of the calculater plz help me sir

9478418880

This is a simple calculator coding. by Gursewak singh

Option Explicit
Dim Op1 As Double, Op2 As Double
Dim Opr As String
Dim cleardisplay As Boolean

Private Sub Cmd0_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd0.Caption
End Sub

Private Sub Cmd1_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd1.Caption
End Sub

Private Sub Cmd2_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd2.Caption
End Sub

Private Sub Cmd3_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd3.Caption
End Sub

Private Sub Cmd4_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd4.Caption
End Sub

Private Sub Cmd5_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd5.Caption
End Sub

Private Sub Cmd6_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd6.Caption
End Sub

Private Sub Cmd7_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd7.Caption
End Sub

Private Sub Cmd8_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd8.Caption
End Sub

Private Sub Cmd9_Click()
If cleardisplay Then
Text1.Text = ""
cleardisplay = False
End If
Text1.Text = Text1.Text + Cmd9.Caption
End Sub

Private Sub CmdC_Click()
Text1.Text = ""
End Sub

Private Sub Cmddiv_Click()
Op1 = Val(Text1.Text)
Opr = "/"
Text1.Text = ""
End Sub

Private Sub CmdDot_Click()
If InStr(Text1.Text, ".") Then
Exit Sub
Else
Text1.Text = Text1.Text + "."
End If
End Sub

Private Sub CmdEqu_Click()
Op2 = Val(Text1.Text)
Select Case Opr
Case "+": Text1.Text = Op1 + Op2
Case "*": Text1.Text = Op1 * Op2
Case "-": Text1.Text = Op1 - Op2
Case "/": Text1.Text = Op1 / Op2
End Select
End Sub

Private Sub CmdMinus_Click()
Op1 = Val(Text1.Text)
Opr = "-"
Text1.Text = ""
End Sub

Private Sub Cmdmul_Click()
Op1 = Val(Text1.Text)
Opr = "*"
Text1.Text = ""
End Sub

Private Sub CmdOFF_Click()
End
End Sub

Private Sub CmdPlus_Click()
Op1 = Val(Text1.Text)
Opr = "+"
Text1.Text = ""
End Sub

Private Sub Form_Load()
Text1.Text = ""
End Sub

thank you!! really helped

thank you!! really helped me...:)

its great! can you help me

its great!
can you help me in my problem!
i can't see the code of scientific calculator,
in professional it so easy but in me its hard...
thanks..

eow.... plz... help me

eow....
plz... help me !asyy
my problem is i can't see the code of scientific calculator in professional it easty but to me it's hard plz. answer my problem

please help me to my equals

please help me to my equals code

hi

what are the codes if the calculator has a button of ON/OFF ????

Urgent Please help

Greetings
Would it be possible for somebody to help me?
I've been asked to write a program through VBS can somebody please help me?\
The details I've been given are below... Can you please email me at Swiksta@hotmail.com

You are required to calculate the insurance premiums for a number of houses. Details are as follows.

Premium rates per square metre are:
Brick = $3
Timber = $5
Other = $4

If the house is in the Sydney metro area a surcharge of 15% applies.

GST rate is 10%

Input is:
Customer's name
Area of house in square meters
Type of dwelling
City Location

You are required to print out the following
Name
Dwelling type
Premium
GST
Total premium

You need to keep processing until there are no more imputs

I've also been asked to include error tracking for the input for 'area of house' and 'dwelling type'

tnx for your concern,

tnx for your concern, sharing your knowleged in using a vb and helping the student...

To any Please........

Hi! may you assist me on how can i get started with vb6, i want to become a popular programmer. assist me the codes for library book tracking system

games

i like the hangman game it is simple but really clever.

Code for Addition

Private Sub CMD1_Click()
TextBox.Text = TextBox.Text & "1"
End Sub

Which code use for to add two numbers.
Please send simple CODE.

its simple

tk any 2 variable
locate ur 1 no at 1 variable
n locate ur command (+) on another variable
then
on "=" button coding there
[text1.text = a + val(text1.text)]

I WANT 2 MEET U PRITI call

I WANT 2 MEET U PRITI
call me at 9478418880

CODE

CODE

Help

Please i am writing a vb project on hospital billing. I seem to be having problem with saving a new patient record. A runtime eror 3426 "This action was cancelled by an associated object" kept showing. I used a data control to access my database. Please help.
using the following code foe my Add New botton

Data1.Recordset.AddNew

percent button

i am new to vb and our instructor told us to make the calculator. i am already done with all the stuff except for the percent, it really wont work out whatever i try..please help me to get the percent ..thanks..

i want the perfect coding

i want the perfect coding for making a SIMPLE CALCULATOR in vb

suggestion

Public a1 As Double, a2 As Double, result As Double, degri As Double
Public a As String, tem As Integer
Public mrc As String
Private Sub chk_Click()
txt.Text = ""
If (chk.Value = 1) Then
cmd0.Enabled = False
cmd1.Enabled = False
cmd2.Enabled = False
cmd3.Enabled = False
cmd4.Enabled = False
cmd5.Enabled = False
cmd6.Enabled = False
cmd7.Enabled = False
cmd8.Enabled = False
cmd9.Enabled = False
cmdpm.Enabled = False
cmdadd.Enabled = False
cmdsqrt.Enabled = False
cmdsub.Enabled = False
cmdpo.Enabled = False
cmdpow.Enabled = False
cmdequal.Enabled = False
cmddiv.Enabled = False
cmdmul.Enabled = False
cmdx.Enabled = False
cmdc.Enabled = False
chkm.Enabled = False
cmdbak.Enabled = False
cmdsin.Enabled = False
cmdcos.Enabled = False
cmdtan.Enabled = False
cmdlog.Enabled = False
txt.Enabled = False
Else
cmd0.Enabled = True
cmd1.Enabled = True
cmd2.Enabled = True
cmd3.Enabled = True
cmd4.Enabled = True
cmd5.Enabled = True
cmd6.Enabled = True
cmd7.Enabled = True
cmd8.Enabled = True
cmd9.Enabled = True
cmdpm.Enabled = True
cmdadd.Enabled = True
cmdsqrt.Enabled = True
cmdsub.Enabled = True
cmdpo.Enabled = True
cmdpow.Enabled = True
cmdequal.Enabled = True
cmddiv.Enabled = True
cmdmul.Enabled = True
cmdx.Enabled = True
cmdc.Enabled = True
cmdbak.Enabled = True
chkm.Enabled = True
cmdsin.Enabled = True
cmdcos.Enabled = True
cmdtan.Enabled = True
cmdlog.Enabled = True
txt.Enabled = True
End If
End Sub
Private Sub cmdbak_Click()
If Val(txt.Text) <> 0 Then
txt.Text = Left$(txt.Text, Len(txt.Text) - 1)
result = Val(txt.Text)
End If
End Sub

Private Sub chkm_Click()
If chkm.Value = 1 Then
mrc = Val(txt.Text)
Else
txt.Text = mrc
End If
End Sub

Private Sub cmdlog_Click()
a1 = txt.Text
a = "log"
txt.Text = ""
result = Log(a1)
If a = "log" And a1 <> 0 Then
txt.Text = result
End If
End Sub

Private Sub cmdpm_Click()
txt.Text = "-"
End Sub

Private Sub cmd0_Click()
txt.Text = txt.Text & 0
End Sub

Private Sub cmd1_Click()
txt.Text = txt.Text & 1
End Sub

Private Sub cmd2_Click()
txt.Text = txt.Text & 2
End Sub

Private Sub cmd3_Click()
txt.Text = txt.Text & 3
End Sub

Private Sub cmd4_Click()
txt.Text = txt.Text & 4
End Sub

Private Sub cmd5_Click()
txt.Text = txt.Text & 5
End Sub

Private Sub cmd6_Click()
txt.Text = txt.Text & 6
End Sub

Private Sub cmd7_Click()
txt.Text = txt.Text & 7
End Sub

Private Sub cmd8_Click()
txt.Text = txt.Text & 8
End Sub

Private Sub cmd9_Click()
txt.Text = txt.Text & 9
End Sub
Private Sub cmdpo_Click()
If InStr(txt.Text, ".") > 0 Then
Beep
Else
txt.Text = txt.Text & "."
End If
End Sub

Private Sub cmdadd_Click()
If a = "+" Then
a1 = a1 + Val(txt.Text)
a = "+"
txt.Text = ""
Else
a1 = txt.Text
a = "+"
txt.Text = ""
End If
End Sub

Private Sub cmddiv_Click()
a1 = txt.Text
a = "/"
txt.Text = ""
End Sub

Private Sub cmdmul_Click()
a1 = txt.Text
a = "*"
txt.Text = ""
End Sub

Private Sub cmdsin_Click()
degri = txt.Text
a = "sin"
txt.Text = ""
a1 = (degri * 22) / 180 * 7
result = Sin(a1)
If a = "sin" Then
txt.Text = result
End If
End Sub
Private Sub cmdcos_Click()
degri = txt.Text
a = "cos"
txt.Text = ""
a1 = (degri * 22) / 180 * 7
result = Cos(a1)
If a = "cos" Then
txt.Text = result
End If
End Sub
Private Sub cmdtan_Click()
degri = txt.Text
a = "tan"
txt.Text = ""
a1 = (degri * 22) / 180 * 7
result = Tan(a1)
If a = "tan" Then
txt.Text = result
End If
End Sub
Private Sub cmdtcot_Click()
degri = txt.Text
a = "cot"
txt.Text = ""
a1 = (degri * 22) / 180 * 7
result = 1 / Tan(a1)
If a = "cot" Then
txt.Text = result
End If
End Sub

Private Sub cmdsub_Click()
a1 = txt.Text
a = "-"
txt.Text = ""
End Sub
Private Sub cmdsqrt_Click()
a1 = txt.Text
a = "sqrt"
txt.Text = ""
a2 = Val(txt.Text)
If a = "sqrt" And a1 > 0 Then
result = a1 ^ 0.5
txt.Text = result
Else
txt.Text = "can't sqrt negative Integer"
End If
End Sub
Private Sub cmdpow_Click()
a1 = txt.Text
a = "pow"
txt.Text = ""
End Sub
Private Sub cmdx_Click()
a1 = txt.Text
a = "1/x"
txt.Text = ""
If a = "1/x" Then result = 1 / a1
txt.Text = result
End Sub
Private Sub cmdc_Click()
txt.Text = ""
a1 = 0
End Sub

Private Sub cmdequal_Click()
a2 = Val(txt.Text)
If a = "+" Then result = a1 + a2
If a = "-" Then result = a1 - a2
If a = "*" Then result = a1 * a2
If a = "pow" Then result = a1 ^ a2
If a = "/" And a2 <> 0 Then result = a1 / a2
txt.Text = result
If a = "/" And a2 = 0 Then txt.Text = "Can't divided by zero"
End Sub
Private Sub info_Click()
Dim s As String
MsgBox ("This is Program for a calculator prpared by vikram")
End Sub
Private Sub help1_Click()
MsgBox ("It can be use on the base of visual basic programing only ! thanks")
End Sub

Private Sub exit_Click()
End
End Sub

Private Sub txt_Change()
Dim check As String
If txt.Text = "a" Or txt.Text = "b" Or txt.Text = "c" Or txt.Text = "d" _
Or txt.Text = "e" Or txt.Text = "f" Or txt.Text = "g" Or txt.Text = "h" Or _
txt.Text = "i" Or txt.Text = "j" Or txt.Text = "k" Or txt.Text = "l" Or txt.Text = "m" _
Or txt.Text = "n" Or txt.Text = "o" Or txt.Text = "p" Or txt.Text = "q" Or txt.Text = "r" Or _
txt.Text = "s" Or txt.Text = "t" Or txt.Text = "u" Or txt.Text = "v" Or txt.Text = "w" Or _
txt.Text = "x" Or txt.Text = "y" Or txt.Text = "z" Then
MsgBox ("Enter Numeric value ! thanks")
txt.Text = ""
End If
End Sub

its quit to long its better

its quit to long its better to program that in array form... i have a code for the cellphone calculator..

if you like to that cellphone

if you like to that cellphone calculator program i can give you...

program

can you give me a copy of cellphone calculator program..
tnx in advanced..

Thank You It works

Thank You It works

lord>.......

thank you lord>.........

..

nice..

need to know

hello, i just want to learn all about calculator..using option button..so could you please teach me how to make a right code..thank you

Coding fOr calculator

plz send me coding for scientific calculator using VB.net .

INPUTBOX

how can i get the value of Val(InputBox("Enter a name:")) ?
so that the name the user inputs will be displayed in a control label..
msg me in fb..
mimih.chaw@yahoo.com

TY

simple

use
label.caption
command

try this.. name =

try this..

name = Inputbox("Enter a name:")

help me..

hoe to creating percentage coding. please help me. thank you so much.

hi to know the vb6.0 please

hi to know the vb6.0 please you can help me to do a simple calculator because i do not know to do please try to give me and simple calculator

cadizjamerlyn@yahoo.com

why vb is very difficult? i dont understand please help me to understand this vb?because i glad to understand vb?

VB is not at all

VB is not at all difficult.......
Its most easy GUI which is present 2de....
If u want to knw of it then pusrchase Visual Basic 6.0 BLACK BOOK... it vil help u....

HELP PLEASE

Dear Sir,
Iam making a calculator in VB6, but i dont know the codings for some functions like: Percentage, SquareRoot, SIN, COS and TAN. I will be very great full to you if you can help me in this, Please contact me through my email ID.

ThankYou
Asjad

P.S - I really need the codings for my project. Please help me....

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.