I want to write a program that will process simple algebra problems.
For example, I want to be able to input...
3x + 15 = 11 - x, and have it process it in the normal way.
4x = -4
x = -1
just like that. I have started writing the program...what I have so far is.
Private Type monomial
CoEfficent As Integer
Variable As String * 1
Degree As Integer
Private Sub Command1_Click()
Dim eS As String
eS = Text1.Text
Dim lhs As String
Dim rhs As String
Dim monomial As String
lhs = Trim(Left(eS, InStr(eS, "=") - 1))
rhs = Trim(Right(eS, Len(eS) - InStr(eS, "=")))
Dim iCount As Integer
For iCount = 1 To Len(lhs)
If IsNumeric(Mid(lhs, iCount, 1)) = False Then
If isLetter(LCase(Mid(lhs, iCount, 1))) = True Then
'now, pull out the entire monomial...for processing.
For jCount = iCount To 1 Step -1 'step backwards
If (Mid(lhs, jCount, 1) = vbspace) Or (jCount = 1) Then
monomial = Mid(lhs, jCount + 1, iCount - jCount + 1)
For iCount = 1 To Len(rhs)
If IsNumeric(Mid(rhs, iCount, 1)) = False Then
If isLetter(LCase(Mid(rhs, iCount, 1))) = True Then
'we found a variable!
Private Function isLetter(char As String) As Boolean
Dim allowed As String
allowed = "abcdefghijklmnopqrstuvwxyz"
If InStr(allowed, char) = False Then
isLetter = False
isLetter = True
of course this code is kinda messed up, I just need some suggestions as to a good way to parse a string, extract monomials and integers and try to figure out what we are supposed to do.