VB.net Calculator
Page 1 of 110 Replies - 83541 Views - Last Post: 07 December 2010 - 01:57 PM
#1
VB.net Calculator
Posted 20 March 2006 - 02:47 PM
Replies To: VB.net Calculator
#2
Re: VB.net Calculator
Posted 20 March 2006 - 02:56 PM
ok since what your trying to do is a very common project ill suggest you look at this Vb.net Calculator Project , its got nice explanation
This post has been edited by Xenon: 20 March 2006 - 02:58 PM
#4
Re: VB.net Calculator
Posted 08 September 2007 - 09:41 AM
Hi! I need to build a calculator, but I need to insert the numbers in a text box using my keyboard. Can anyoane help me with this? I don't know how to make the text box accept only numbers and how to work with the numbers I assign (from keyboard). Thank you.
#5
Re: VB.net Calculator
Posted 09 September 2007 - 06:37 PM
#6
Re: VB.net Calculator
Posted 26 July 2008 - 02:44 AM
Xenon, on 20 Mar, 2006 - 02:56 PM, said:
ok since what your trying to do is a very common project ill suggest you look at this Vb.net Calculator Project , its got nice explanation
I went to this site but I'm stuck on the equals button exercise. There is a third line of code that resets the variable total1 to zero and I'm having trouble thinking of what it is.
Here is my code:
Public Class Form1 Dim total1 As Integer Dim total2 As Integer Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthree.Click txtDisplay.Text = txtDisplay.Text & btnthree.Text End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnseven.Click txtDisplay.Text = txtDisplay.Text & btnseven.Text End Sub Private Sub btnzero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnzero.Click txtDisplay.Text = txtDisplay.Text & btnzero.Text End Sub Private Sub btnone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnone.Click txtDisplay.Text = txtDisplay.Text & btnone.Text End Sub Private Sub btntwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntwo.Click txtDisplay.Text = txtDisplay.Text & btntwo.Text End Sub Private Sub btnfour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfour.Click txtDisplay.Text = txtDisplay.Text & btnfour.Text End Sub Private Sub btnfive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfive.Click txtDisplay.Text = txtDisplay.Text & btnfive.Text End Sub Private Sub btnsix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsix.Click txtDisplay.Text = txtDisplay.Text & btnsix.Text End Sub Private Sub btneight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneight.Click txtDisplay.Text = txtDisplay.Text & btneight.Text End Sub Private Sub btnnine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnine.Click txtDisplay.Text = txtDisplay.Text & btnnine.Text End Sub Private Sub cmdPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPlus.Click total1 = total1 + Val(txtDisplay.Text) txtDisplay.Clear() End Sub Private Sub cmdEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEquals.Click total2 = total1 + Val(txtDisplay.Text) txtDisplay.Text = total2
End Sub
End Class
I think I figured it out. Here is what I did.
total1 = btnzero.Text
I can't believe it took me a whole day to figure that out.
This post has been edited by seadannie: 26 July 2008 - 10:15 PM
#7
Re: VB.net Calculator
Posted 01 December 2009 - 05:11 PM
vatyk, on 8 Sep, 2007 - 08:41 AM, said:
Hi! I need to build a calculator, but I need to insert the numbers in a text box using my keyboard. Can anyoane help me with this? I don't know how to make the text box accept only numbers and how to work with the numbers I assign (from keyboard). Thank you.
Just add textbox to your form and type stuff into it that simple
#8
Re: VB.net Calculator
Posted 03 December 2009 - 09:29 PM
Why has this thread been revived every year since 2006?
If any more questions come up check PsychoCoders tutorial for a basic calculator.
If you need a more advance calculator check http://www.vbprogram...dCalculator.htm
Remember people when 2010 comes post in here
If any more questions come up check PsychoCoders tutorial for a basic calculator.
If you need a more advance calculator check http://www.vbprogram...dCalculator.htm
Remember people when 2010 comes post in here
#9 Guest_smart_alec*
Re: VB.net Calculator
Posted 20 February 2010 - 08:57 PM
Ok, it's 2010... Somebody had to... 
some_kid, on 03 December 2009 - 08:29 PM, said:
Why has this thread been revived every year since 2006?
If any more questions come up check PsychoCoders tutorial for a basic calculator.
If you need a more advance calculator check http://www.vbprogram...dCalculator.htm
Remember people when 2010 comes post in here
If any more questions come up check PsychoCoders tutorial for a basic calculator.
If you need a more advance calculator check http://www.vbprogram...dCalculator.htm
Remember people when 2010 comes post in here
#10 Guest_spike*
Re: VB.net Calculator
Posted 26 March 2010 - 01:10 AM
seems like I cant make this equal button to work properly...doesn't even add the 1st value to the current txtdisplay.text... nid ur help pls!
Private Sub btnEqual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEqual.Click
'Dim total2 As Integer
total2 = total1 + Val(txtDisplay.Text)
txtDisplay.Text = total2
MsgBox(total2)
End Sub
End Class
Private Sub btnEqual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEqual.Click
'Dim total2 As Integer
total2 = total1 + Val(txtDisplay.Text)
txtDisplay.Text = total2
MsgBox(total2)
End Sub
End Class
#11 Guest_omar Abdo*
Re: VB.net Calculator
Posted 07 December 2010 - 01:57 PM
spike, on 26 March 2010 - 12:10 AM, said:
seems like I cant make this equal button to work properly...doesn't even add the 1st value to the current txtdisplay.text... nid ur help pls!
Private Sub btnEqual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEqual.Click
'Dim total2 As Integer
total2 = total1 + Val(txtDisplay.Text)
txtDisplay.Text = total2
MsgBox(total2)
End Sub
End Class
Private Sub btnEqual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEqual.Click
'Dim total2 As Integer
total2 = total1 + Val(txtDisplay.Text)
txtDisplay.Text = total2
MsgBox(total2)
End Sub
End Class
You have to define total1 and total2 at the top of your form
01 Public Class Form1
02
03 Dim total1 As Integer
04 Dim total2 As Integer
DON'T DEFINE THEM AGAIN AT EACH BUTTON
I HOPE THAT'S HELPFUL
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|