Thanks --- In [EMAIL PROTECTED], "Tim Rupp" <[EMAIL PROTECTED]> wrote: > Try this...it's about as simple as I can make it and it should point you > in the direction. > > > Dim Temporary As Double > Dim Operand1 As Double > Dim CalcInProcess As Boolean > > Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles TextBox1.TextChanged > Temporary = Val(TextBox1.Text) > End Sub > > Private Sub Button1_Click(ByVal sender As Object, ByVal e As > System.EventArgs) Handles Button1.Click > If CalcInProcess = False Then 'This is the first operand input > Operand1 = Temporary > TextBox1.SelectionStart = 0 > TextBox1.Select(TextBox1.SelectionStart, TextBox1.TextLength) > TextBox1.Focus() > CalcInProcess = True > Else 'We will now do the addition operation > TextBox1.Text = Temporary + Operand1 > TextBox1.SelectionStart = 0 > TextBox1.Select(TextBox1.SelectionStart, TextBox1.TextLength) > TextBox1.Focus() > CalcInProcess = False > End If > End Sub > > > HTH, > Tim > > > > -----Original Message----- > From: sramey28 [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 31, 2004 12:55 PM > To: [EMAIL PROTECTED] > Subject: [vbhelp] Re: trying to make calculator with vb.net > > > Ok Tim I worked with what you told me. Here is my code now. I don't > understand how you are resetting the cursor back to first character > before the operator Add ect. is clicked. So then I can't assign that > number to opt2. Right now I can enter 1 number click + and then > enter a new number. I then click = and the answer given is the > second number plus itself. The first number is ignored, so the > second number is being assigned to opt1 and replacing the first > number. So the assignment of a number to (opt2) isn't happening. I > think there should be more to the textchange of the textbox but > what? > > 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 = opt1 + opt2 > > End Function > > Private Sub btnAdd_Click( _ > ByVal sender As System.Object, _ > ByVal e As System.EventArgs) _ > Handles btnAdd.Click > txtEnter.Clear() > txtEnter.ResetText() > txtEnter.Text = String.Empty > > number = Nothing 'this clears the box so only the next > number I enter appears, but then I think this cancels out the first > number. > > End Sub > > Private Sub txtEnter_TextChanged( _ > ByVal sender As Object, _ > ByVal e As System.EventArgs) _ > Handles txtEnter.TextChanged > opt1 = Val(txtEnter.Text) > opt2 = Val(txtEnter.Text) 'where do I put this line. > End Sub > > Private Sub btnEqual_Click( _ > ByVal sender As Object, _ > ByVal e As System.EventArgs) _ > Handles btnEqual.Click > opt2 = Val(txtEnter.Text) 'does it go here > Addition() > txtEnter.Text = CStr(answer) > End Sub > > --- In [EMAIL PROTECTED], "sramey28" <[EMAIL PROTECTED]> wrote: > > Thanks this should be a big help. > > > > > > --- In [EMAIL PROTECTED], "Tim Rupp" <[EMAIL PROTECTED]> wrote: > > > Why do anything at all with number presses....let your text box > > hold the > > > value as it is entered from the keystrokes using the > > TextBox.TextChanged > > > method to gather your input number. Perhaps you want to verify > > that the > > > keystroke is numeric, decimal point, and perhaps A-E if your > going > > to > > > allow hex calculations...but that's your choice. When the > operand > > key is > > > hit (+,-,/,*) just take the value of your text display and > assign > > that > > > to a temporary value (Operand1 = Val(txtEnter.Text) ) > > > > > > At that point I'd highlight the text in the text box and reset > the > > > cursor to the first character so that the next keystroke entry > will > > > clear your text box. Then assign the second operand and perform > the > > > operation in the same manner when the equals key or successive > > > calulation key is struck. At that point you would perform the > > > calculation, assign the result to your result value, and display > > that > > > value in your text box (once again highlighting the text and > > placing the > > > cursor at the beginning of the field so that additional entries > > from the > > > keyboard once again clear your display. > > > > > > For even more fun, try the RPN calculator type! > > > > > > Enjoy, > > > tim > > > > > > > > > -----Original Message----- > > > From: sramey28 [mailto:[EMAIL PROTECTED] > > > Sent: Monday, August 30, 2004 4:57 PM > > > To: [EMAIL PROTECTED] > > > Subject: [vbhelp] trying to make calculator with vb.net > > > > > > > > > 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 > > > > > > > > > > > > > > > > > > '// ======================================================= > > > 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 Sponsor > > > > > > ADVERTISEMENT > > > > > > > > > <http://us.ard.yahoo.com/SIG=129cblskp/M=298184.5285298.6392945.30011 > > 76/ > > > > > > D=groups/S=1705115364:HM/EXP=1093987023/A=2319501/R=0/SIG=11tq0u909/* > > htt > > > p://www.netflix.com/Default?mqso=60185353&partid=5285298> click > > here > > > > > > <http://us.adserver.yahoo.com/l? > > M=298184.5285298.6392945.3001176/D=group > > > s/S=:HM/A=2319501/rand=680771713> > > > > > > > > > _____ > > > > > > 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] > > > <mailto:[EMAIL PROTECTED] subject=Unsubscribe> > > > > > > > > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of > > > Service <http://docs.yahoo.com/info/terms/> . > > > > > > > > > > > > > > > [Non-text portions of this message have been removed] > > > > > > '// ======================================================= > 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 Sponsor > > ADVERTISEMENT > > <http://us.ard.yahoo.com/SIG=129ngghpm/M=298184.5285298.6392945.30011 76/ > D=groups/S=1705115364:HM/EXP=1094058811/A=2319501/R=0/SIG=11tq0u909/* htt > p://www.netflix.com/Default?mqso=60185353&partid=5285298> click here > > <http://us.adserver.yahoo.com/l? M=298184.5285298.6392945.3001176/D=group > s/S=:HM/A=2319501/rand=238205055> > > > _____ > > 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] > <mailto:[EMAIL PROTECTED]> > > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of > Service <http://docs.yahoo.com/info/terms/> . > > > > > [Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/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/
