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.

 

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?

baka binary yan jejejejej

baka binary yan jejejejej

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 :)

Computer sccience

Plz send me code for back space button in calculator

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

root

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

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

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.

More information about formatting options