Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 1st, 2005, 5:01 PM   #1
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Question

Alright usually I wouldnt get involved in visual basic 6, im more intrested in C++, but this is the only computer class my school has so I took it, im way ahead of the class because I know a bunch of this stuff already. Anyways Im working on a little project for fun, and part of it is a dynamic calculator

so you can have equations entered like 4 * (4+3) * rand(4,6) + (3 + (4-5)) - 2(3)

and of couse it would all go long with the order of operations... anyone have any idea how to write a command sub that could solve something like that? ps - rand is rand(min, max) it finds a number in between or equal to the ones given... if you can just give me an idea of where to start thatd be great.
brokenhope is offline   Reply With Quote
Old Sep 6th, 2005, 2:00 AM   #2
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
Label1.Caption = 4 * (4 + 3) * (Int(10 * Rnd())) + (3 + (4 - 5)) - 2 * (3)

i made a form with a label called label1 and made the caption property equal to the expression you gave with ONE difference...

well two... i made the last operation 2*(3) instead of 2(3)

i don't know rand but i know Rnd

Int(10*Rnd()) gives a random number between 0 and 9. the answer was 192

and don't use quotes around the expression or it'll evaluate it as a character string and you'll just get back what you already typed in.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 6th, 2005, 12:26 PM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I think what he wants is for the user to be able to type the equation in. Googling found this:

http://www.developerfusion.co.uk/show/198/
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 6th, 2005, 6:46 PM   #4
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Yes that was exactly what I was looking for, thank you.
brokenhope is offline   Reply With Quote
Old Sep 6th, 2005, 8:25 PM   #5
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
...

I didnt know I had to download an .OSX to get it to work, so I spoke to soon. I cant find the OSX file mentioned anywhere, ive looked all over msdn, where they said it was, I went to google and searched Visual Basic Eval, and the closest thing I found was someones self programmed version of it, but it was only a demo so I couldnt use it... anyone know where its at? or anything?
brokenhope is offline   Reply With Quote
Old Sep 7th, 2005, 7:11 AM   #6
ViOLATiON
Programmer
 
Join Date: Sep 2005
Posts: 58
Rep Power: 4 ViOLATiON is on a distinguished road
Quote:
To download this OCX, visit http://msdn.microsoft.com/scripting/
Select the Script Control link, then follow the Download
instructions. The following code shows the simple VB we added
to a command button's click event. The SC1 script control
evaluates a mathematical formula in the txtFormula textbox.
I guess you had trouble with the instructions, so here's a direct link:
http://www.microsoft.com/downloads/d...displaylang=en
ViOLATiON is offline   Reply With Quote
Old Sep 7th, 2005, 2:32 PM   #7
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Quote:
Originally Posted by ViOLATiON
I guess you had trouble with the instructions, so here's a direct link:
http://www.microsoft.com/downloads/d...displaylang=en
Gentoo has problems with genuine winblows evaluation, yes.

Embed a web control and navigate to the google calculator!

Or better still use the web control to expose the Javascript eval(); function.
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:01 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC