![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 126
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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/ |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 126
Rep Power: 4
![]() |
Yes that was exactly what I was looking for, thank you.
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Apr 2005
Posts: 126
Rep Power: 4
![]() |
...
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?
|
|
|
|
|
|
#6 | |
|
Programmer
Join Date: Sep 2005
Posts: 58
Rep Power: 4
![]() |
Quote:
http://www.microsoft.com/downloads/d...displaylang=en |
|
|
|
|
|
|
#7 | |
|
Expert Programmer
|
Quote:
Embed a web control and navigate to the google calculator! Or better still use the web control to expose the Javascript eval(); function. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|