Hi, I'm trying to learn vb.net for work. I only have books and
online class and online help to learn from. I'm trying to make a
simple calculator. here is some of my code. The btnNine_click is
just like procedures for the numbers 0-8. What I need help with is
the idea of the Display (txtEnter) showing the right numbers. Right
now I'm only working on addition of numbers. I'm not sure if the
addition function has to be a function or sub. Here are the steps to
my problem.
1. any number is clicked.
2. This number shows up in display
3. Click the (add +) button
4. previous number disappears, leaving display blank
5. Next Click another number.
6. That one appears in display
7. Now click (equal =) button
8. The answer displayed is First number plus itself.
I think my problem lies in the Addition function line:
answer = Double.Parse(number) + Double.Parse(lblNum.Text)
both number and lblNum.text point to the same number.
Main question
How do I get the second number entered recongized and added to the
first number entered. This easy if there are two textboxes, but with
one I don't know how to do this.
Private Sub btnNine_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnNine.Click
number = number + "9"
txtEnter.Text = number
End Sub
Private Sub btnDecimal_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnDecimal.Click
number = number + "."
txtEnter.Text = number
End Sub
Public Function Addition() As Integer
answer = Double.Parse(number) + Double.Parse(lblNum.Text)
lblNum.Text = String.Empty 'cleared for 2nd number enter
number = "" 'tried clear number variable for second number
End Function
Private Sub btnAdd_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd.Click
lblNum.Text = CStr(number) 'These two lines are more
txtEnter.Text = String.Empty 'of trying to clear the
Addition() 'number
End Sub
Private Sub btnEqual_Click( _
ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnEqual.Click
txtEnter.Text = CStr(answer)
End Sub
Thanks sramey28
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [EMAIL PROTECTED]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/