944,044 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 5520
  • VB.NET RSS
Oct 19th, 2007
0

VB.NET Calculator

Expand Post »
Hi, i'm trying to create a vb.net calcualtor similar to that of windows but with more functions, the problem is that i can't think of how i can use a single text box to get the two input numbers. i've tried using .visible but still does not work.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Bands is offline Offline
2 posts
since Sep 2007
Oct 19th, 2007
0

Re: VB.NET Calculator

Hi,

I did something like this myself. Use two variables (ie: Dim dblVal1 As Double, dblVal2 As Double).

Pass the 1st test entry to dblVal1, clear the text box (when the user presses a function key such as '+'), then pass the 2nd text box entry to dblVal2.

HTH, Chris.
Reputation Points: 10
Solved Threads: 4
Junior Poster in Training
Chris147 is offline Offline
58 posts
since Jun 2007
Oct 19th, 2007
-1

Re: VB.NET Calculator

just use cache to perform this type of operation...
It will b fine.
Reputation Points: 5
Solved Threads: 1
Junior Poster in Training
preetham.saroja is offline Offline
82 posts
since Jun 2007
Mar 7th, 2009
0

Re: VB.NET Calculator

Adding to Numbers using your Numeric keypad VB.NET 2003
Just drag 1 label to your form
label1.backcolor = color.black
label1.forecolor = color.green
make some adjustments to your font as you want

Declare your variables

in your form use the KeyUp event
and place the code below
VB.NET Syntax (Toggle Plain Text)
  1. Private f as String 'your first number
  2. Private s as String 'your second number
  3. private n as String
  4. private o as String 'this will be your operators variable
  5. Private sum as Double
  6.  
  7. Private Sub MainForm_KeyUp(Byval sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
  8.  
  9. Select case e.KeyCode
  10. Case keys.Numpad0, keys.NumPad1 '(provide all the keycodes)
  11. f = e.KeyCode.ToString 'this will display what key your pressed
  12. f = f.Substring(6, 1) 'we will extract the last string of the keycode string
  13. n = n & f 'we will pass our first number to our variable n
  14. me.label1.Text = n 'we will display whats on variable n
  15.  
  16. Case keys.Decimal 'hmmm we will make some flavoring here
  17. n = n & "."
  18. f = ""
  19. n = n & f
  20. Case keys.Add
  21. o = "+" 'assign a plus sign to operators variable
  22. s = n 'we will pass our first number to the second number
  23. sum= Val(s) + Val(r) '
  24. me.label1.Text = FormatNumber(sum, 2, TriState.True, TriState.True, TriState.True)
  25. n = ""
  26. r = sum
  27. Case keys.Subtract
  28. 'do your part, explore, and discover something extraordinary
  29. 'happy coding
  30. End Select

so if i hopes there's nothing missing on the codes
Reputation Points: 11
Solved Threads: 10
Junior Poster in Training
c0deFr3aK is offline Offline
71 posts
since Mar 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: vb.net setup file
Next Thread in VB.NET Forum Timeline: How to print multiple pages from database record





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC