|
-
Feb 4th, 2000, 02:45 AM
#1
Thread Starter
New Member
I am new to VB and I am attemping to create a numeric calculator with basic math functions(+-*/)
I have created the form using a text box for the display and command buttons for each number 0-9 and each function.
Does anyone know how I should go about attaching the code and how it should read?
Thanks in advance for any help!
-
Feb 4th, 2000, 03:48 AM
#2
Hyperactive Member
It depends on exactly what you mean. Code to simply take teh number they clicked and add it to the display?
txtDisplay.text = txtDisplay & Value from button.
I did something like that years ago and I found it easiest to make the number buttons an array with the index being the number. Then on hte _Click event(index as integer) I would know what number was clicked and could simply use that:
cmdNumbers(0) = 0
cmdNumbers(1) = 1
That made it easy to know what number to place in the display. Then just a matter of storing the display value into either a hidden field or private string when they click on an operator (add, subtract etc).
Hope this helps. If you want more info email me and I'll send it to you.
I like your reference to the Wolfman... unless I'm wrong in whcih case ignore this part of the message :-)
[This message has been edited by netSurfer (edited 02-04-2000).]
-
Feb 4th, 2000, 09:29 AM
#3
Thread Starter
New Member
Thank you!
That is very helpful. I plan to work with this program over the weekend and will e-mail you if I run into problems.
And yes, Lon Chaney is a reference to the actor who played the wolfman. I am an N C State fan, thus the nickname.
-
Feb 6th, 2000, 02:12 AM
#4
Thread Starter
New Member
How do you go about making the buttons an array?
Told you I was new....
-
Feb 6th, 2000, 03:10 AM
#5
Hyperactive Member
OK name each command button the same thing and it will ask you if you want to create an array. Then if byaccident you do it out of order and the o has an array of 9 you have to fix that in the porperties called index but you must remeber nothing can have the same index so if you want the zero button to have an array of 0 you must first go to the one that actually does say 0 and change it to another number and then go to your zero button and make the array 0. I hope this helps
------------------
Sincerely,
Chris
:-) ;-)
just have fun out there and live life to the fullest while it is still here
Email [email protected]
-
Feb 6th, 2000, 05:57 AM
#6
Thread Starter
New Member
Thanks PB.
Now I have the 0-9 command keys in an array in which I named them all "integer". And I also set the index to match each number on the keyboard.
What code do I use to display the numbers when they are clicked? txtDisplay=? for each number?
[This message has been edited by Lon Chaney (edited 02-06-2000).]
-
Feb 6th, 2000, 07:47 AM
#7
Hyperactive Member
Here is your code:
Private Sub INTEGER_Click(Index As Integer)
TextDISPLAY.Text = TextDISPLAY.Text & Index
End Sub
there that should do it
------------------
Sincerely,
Chris
:-) ;-)
just have fun out there and live life to the fullest while it is still here
Email [email protected]
-
Feb 6th, 2000, 09:25 AM
#8
Thread Starter
New Member
I tried that code, but I'm getting an error message:
Run-time error 424
object required
When I debug, I get this line highlighted:
TextDisplay.Text=TextDisplay.Text & Index
Any ideas?
Thanks!
-
Feb 6th, 2000, 09:33 AM
#9
Hyperactive Member
hmm it seemed to work fine when i tried it let me check again
------------------
Sincerely,
Chris
:-) ;-)
just have fun out there and live life to the fullest while it is still here
Email [email protected]
-
Feb 6th, 2000, 09:42 AM
#10
Hyperactive Member
Hmm i tried the code i gave you again and it worked fine so here is a few ideas dim you make index as anything anywhere if so change the name to something else or did you put that code under
Private Sub INTEGER_Click(Index As Integer)
if you put it under
Private Sub INTEGER_Click
it won't work.
hope this helps
------------------
Sincerely,
Chris
:-) ;-)
just have fun out there and live life to the fullest while it is still here
Email [email protected]
-
Feb 6th, 2000, 12:39 PM
#11
Thread Starter
New Member
OK
I now have a calculator that will display numbers and clear. Now I just need to discover how to set up the addition, subtraction, multiplication, and division functions.
Again, thanks for all the help. What a challange!
Lon
-
Feb 6th, 2000, 10:10 PM
#12
Hyperactive Member
If you need anymore help just email me [email protected] . I would be glad to help. Well talk to you later have fun!!
------------------
Sincerely,
Chris
:-) ;-)
just have fun out there and live life to the fullest while it is still here
Email [email protected]
[This message has been edited by PITBULLCJR (edited 02-07-2000).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|