The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Visual Basic


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags:

Closed Thread
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-10-2007, 05:37 PM
John W
Posts: n/a
[SOLVED] Write in Visual basic language a program of a calculator, please?

That calculator has to do: addition, subtraction, multiplication and division. And it should have an icon to delete the former results and start again.
I really need it, and I will appreciate this a lot, thank you all.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #2 (permalink)  
Old 06-25-2007, 11:25 PM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 317
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
I don't think anyone is going to just "write" this application for you but we would be willing to help you out You would have a class with a private variable holding the Current Value (_CurrentValue). This _CurrentValue starts out with 0... then you can just encapsulate the already existing methods in VB to do addition, subtraction, etc...
  #3 (permalink)  
Old 06-26-2007, 08:22 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,118
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
Quote:
Originally Posted by John W View Post
That calculator has to do: addition, subtraction, multiplication and division. And it should have an icon to delete the former results and start again.
I really need it, and I will appreciate this a lot, thank you all.
What ccoonen said is right, you must post the problem and tried it yourself. I don't think there's someone that's going to all of the sudden with their happiness of coding will write you the program that you want, unless if you want to go to Freelance section of this forum hmm...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #4 (permalink)  
Old 06-26-2007, 10:28 AM
siLenTz's Avatar
siLenTz siLenTz is offline
Jr. Programmer
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Posts: 87
iTrader: (0)
siLenTz will become famous soon enoughsiLenTz will become famous soon enough
This is my first post on this forum so I want to make it useful. I think this
is your assignment so you have to do it on your own. However, I can provide
you some hints to do it on your own.

Creating simple calculator like this is pretty easy. Follow these steps you will
able to complete that program in just a hour:

1)
Creating a form, a textbox which is for input and output the result, 10
buttons of number from 0 to 9, and math operations buttons.

2) Creating 2 variables: first one is for store the first inputed number, and
the second one is operation variable which store what operation that
currently use.

Code:
Dim intVal    As Integer
Dim intOp    As Integer
3) Whenever you click on any operation button, the current value in
textbox will be store in intVal and then store the operation that you clicked
into intOp. intOp = 1 mean the addition operation is used if intOp = 2 mean
the subtraction operation is used, 3 for multipilcation and 4 for division.

The code probally look like this:
Code:
Private Sub bAddtion_Click()
     intOp = 1
     intVal = Text1.Text
     Text1.Text = ""
End Sub

Private Sub bSubtraction_Click()
     intOp = 2
     intVal = Text1.Text
     Text1.Text = ""
End Sub

.... so on.....

4)
On the equal button, the program will calculate between those two
values.

Code:
Private Sub bEqual_Click()
     Select Case intOp
          Case 1:
               Text1.Text = intVal + CInt(Text1.Text)
          Case 2:
               Text1.Text = intVal - CInt(Text1.Text)
          Case 3:
               Text1.Text = intVal * CInt(Text1.Text)
          Case 4:
               Text1.Text = intVal \ CInt(Text1.Text)
     End Case

     intOp = 0

End Sub
5) But some users do not click on the equal button, they directly
click on other operations to continues calculate more number... Here the
solutio. Whenever the users click on each operations button, the program
will check if any operations is currently use. if there is then goto equal
button first.

On each operations button should be look like this
Code:
Private Sub bAddtion_Click()
     If intOp <> 0 Then bEqual_Click()

     intOp = 1
     intVal = Text1.Text
     Text1.Text = ""
End Sub

Private Sub bSubtraction_Click()
     If intOp <> 0 Then bEqual_Click()

      intOp = 2
      intVal = Text1.Text
      Text1.Text = ""
 End Sub

 .... so on.....
My english is very poor. Hope you are understand what I try to
explain. If anyone think is not the best way to do it or have any other way
please give comment

From siLenTz
My first lovely post!

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
The Following User Says Thank You to siLenTz For This Useful Post:
HelloWorld (06-26-2007)
  #5 (permalink)  
Old 06-26-2007, 10:59 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,118
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
Although it's not my question, yeah it is damn useful! I love codes...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #6 (permalink)  
Old 09-06-2007, 08:37 PM
cesarfrancisco
Posts: n/a
Quote:
Originally Posted by John W View Post
That calculator has to do: addition, subtraction, multiplication and division. And it should have an icon to delete the former results and start again.
I really need it, and I will appreciate this a lot, thank you all.
I just uploaded a calculator to MSDN Forum: Show and Tell. It will take 72 hours to publish it (hopefully they will). It has all you want and a little more functions on it. Gladly give you the code if you like the calculator.
I am just a beginner like yourself.
I took a fancy on calculators - ( right now I am trying to finish imitating the MoffSoft Calculator's core ). I will post it also, when and if I am able to finish it).
There is an other Calculator ( the new era one) called Practicalc. This is something awesome for a calculator. Check it out. I got some of the screen functions coded.

On the other hand, I see on this Forum programmers that can do a calculator probably in hours. I would be glad hear for them, because I certainly need some direction with PractiCalc.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Closed Thread


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 04:04 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50