Well, I don’t boast a whole lot about my programming (mainly because I know programmers who are a billion times better than me, ie. Guy Perfect) but today, I think I’ve got something worthwhile. (Skip to the last paragraph if you don’t care about the backstory.)
On and off over the last 28 days (according to my project file’s Created On date) I’ve been working on a program to solve equations. It may seem simple to you, but it’s about as difficult as making a very small programming language. The program must parse the lexicons (numbers, variables, binary operators, unary operators, grouping symbols), fix shorthand (7x is 7 * x), order all the grouping symbols, and run through the rest of the order of operations, repeating the process until all but one lexicon are eliminated.
With such inconsistencies as the Mid function using locations ranging from 1 to the length of the given string (piece of text) compared to the many arrays which start with 0, it’s extremely easy to make a mistake, and any mistake could result horribly. For example, just a few minutes ago, as I was showing the program to the school principal, I realized that I had made a mistake rendering the program entirely useless (except for, specifically, x = e). So I spent a few minutes looking at the code and realized that a snippet I had copied and pasted had a single number incorrect–I used 120 (the ASCII value of “x”) instead of 101 (the ASCII value of “e”), and that resulted exactly as one would expect.
Of course, that mistake was not the only of its kind. The process of my programming is riddled with constant mistakes of overlooking and thinking incorrectly. In short, it took 28 days to make a program of about 600 lines of code which is capable of solving any equation that could be solved by any programmer with just a few lines of code. For example, I have “3(x + 4) - x ^ 2” as my program’s default equation. With just the code
For x = -10 to 10
y = 3* (x + 4) - x ^ 2
txtResults.Text = txtResults.Text & y & vbCrLf
Next x
the equation would be solved and the answer reported for 21 different values of x. But of course, not everyone has a compiler at their disposal; even though it’d probably take a few seconds to get one, they’d have to learn something about the syntax to make it work. I decided on a whim to develop this program, which I thought would also help to hone my skills, and share it with others who may want to play around with it or actually make use of it.
Well, down to business. The program is available for download here, and after a few days (giving time for users to report errors I’ve made), I will probably upload the source code. I have a few minor functions to add, such as resizing the graph, but those aren’t complex enough to require user testing. Please download it and play around a bit!