Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Using A Equations In Textbox

i want to write an equation with all the mathematical symbols in a textbox /Richtextbox. is there any dll which suppoerts it or any other way to do it.
in simple i want to do like how we r writing an equation in word 2000. i tried by adding that exe in my application but i failed to make it work at runtime.
can anyone helps me plz

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
hey does any one know any good tactics for implementing a command line equation editor... well something like you type in an equation, maybe declare some variables.. im woundering how to store the equation and then plug numbers into it.. any adivce would be great

Equations In VB6
Is there a control that makes equations (with squar roots, logarithms, lim-eses etc.)?

Can anyone help me in getting mathematical equations in label/text/richtextbox control in VB?

How would I setup a program that could calculate the following equation: 2x + 3 = 3x - 4

here is my code to get X in the equation aX+b=c

why isn't it giving me decimal numbers for some equations?

Private Sub cmdCalculate_Click()
Dim loopint As Double
Dim pos As Double
Dim pos2 As Double
Dim pos3 As Double

For loopint = 1 To 5
equ(i) = ""
Next loopint

Dim num1 As Double
Dim num2 As Double
Dim num3 As Double
Dim final As Double

equ(1) = txt1.Text ' }
equ(2) = txt2.Text ' }
equ(3) = txt3.Text ' } puts the equations into the array
equ(4) = txt4.Text ' }
equ(5) = txt5.Text ' }

For loopint = 1 To 5
'reset everything
num1 = 0
num2 = 0
num3 = 0
final = 0

'get #1
pos = InStr(equ(loopint), "X")
If pos = 0 Then pos = InStr(equ(loopint), "x")

If Left(equ(loopint), 1) = "X" Or Left(equ(loopint), 1) = "x" Then
num = 0
ElseIf Left(equ(loopint), 1) <> "X" Or Left(equ(loopint), 1) <> "x" Then
num1 = Left(equ(loopint), (pos - 1))
End If

'get #2
pos = InStr(equ(loopint), "+")
If pos = 0 Then
pos = InStr(equ(loopint), "-")
pos2 = InStr(equ(loopint), "=")
num2 = Mid(equ(loopint), (pos + 1), (pos2 - (pos + 1)))
num2 = num2 -1
ElseIf pos <> 0 Then
pos = InStr(equ(loopint), "+")
pos2 = InStr(equ(loopint), "=")
num2 = Mid(equ(loopint), (pos + 1), (pos2 - (pos + 1)))
End If

'get #3
num3 = Right(equ(loopint), (Len(equ(loopint)) - pos2))

If num1 <> 0 Then
final = ((num3 - num2) / num1)
ElseIf num1 = 0 Then
final = (num3 - num2)
End If
answer(loopint) = final

Next loopint
lblAnswer1.Caption = answer(1)
lblAnswer2.Caption = answer(2)
lblAnswer3.Caption = answer(3)
lblAnswer4.Caption = answer(4)
lblAnswer5.Caption = answer(5)
End Sub

Graphing Equations
I need to be able to create graphs for basic algebra equations.

Linear y = 2x + 1
Quadratic y = x^2
Absolute value y = |2x| - 3

Maybe a few others but for now, just linear would be good. Any ideas on this? Is there a control already out there that will do it?

I would also need to be able to print the graphs.

Does Anyone Know The Equations For Fractals
i was thinking of trying out making 'fractals' those things that make weird colourful patterns,

but i cant seem to find any equations to put into a program,
like what is the general equation to make a fractual, if someone would have an example in pseudocode or vb?

Trigonometrical Equations In Vb
hi there, I have this little problem: when I'm trying to calculute cos(1), the result is -0,44, when it should be 0! What am I doing wrong? thanx in advance!

Linear Equations
mmmmm. I don't know if it's the right category to post this, but here I go. I found on inet, part of the code to solve Simultaneous Linear Equations. Works great for me, but I'm programming for Palm with the MobileVB from Appforge (Add IN for VB 6.0, Some of these devices don't have keys at all. Everything is done with screen touch. The problem, to summerize, is that it takes a lot of time to enter the Equations, (matrix form), even with a little keyboard I made.
Actually, there's no problem at all, if the equation is organized:

2A + 3b -c = 3 --> Enter each coefficient
... .... .... (Rest of equations)

Trouble comes for:

A/2 + A/3 + 1.5 B + 5b/8 + c/7 = 15/7
... ... ...

See what I mean? So I have been looking for a way to enter in a field box
the whole equation, and have the program organize it and simplifies it.


Linear Equations
How would you program the program to understand a equation lets say containing one variable from a text box in vb6???

String Equations...
is there an easy way to calculate a maths calculation within a string? ie. the user types in "2 + 5 / 2" and the answer can be returned. Ive tried using Val but it desnt seem to support division or multiplication!

Dates And Equations
This is a simple question, but Im getting terribly confused at this point, so thanks for any help you can provide!

What I have is a form in access which compares two dates and determines if the product is overdue or onschedule.

I have a Text box with a due date.
I have a Text box with the actual date it was received.

My code is as follows:

If [Ackn_of_Receipt_Due] > Date And IsNull(Me![Date Received]) Then
Label22.Caption = "OVERDUE!"
Label22.Caption = "On Schedule"

Unfortunately its not working. I have 7 records. The first 4 have Due dates dated for april and nothing typed in for date received...naturally it says OVERDUE!

My 5th record has Nothing typed into either field and it says "on schedule" - which I guess I dont mind.

My 6th record however, has a due date of late august this year and nothing written in date received....but it says "overdue!" and not "onschedule"

Please help! Thank you so much : )

Simultaneous Equations
Whats the best way to to solve two equations simultaneouly? The method i use at the minute is to store each of the coeficients separatly. Then work on them. One equation is linear the other isn't.


Equations [done = True]
Howdy all,

I was wondering if there is an easy way to find the result of equations stored in a string. I don't usually use Numbers alot in VB, so I'm not entirely sure. I need something that will handle nearly any equation, such as..


Any help would be appreciated..


Working With Equations
I want to make a simple program that solves simple mathematical expressions..for example
if user types the following in one of the text box

where a and b are two variables and their values are determined by the program.
Is there anyway to evaluate a string expression as a mathematical piece.

Input Equations
I would like to know how to get an equation inputted from the user in the form y = mx + b

the y values will be calculated in my app via an array of x values so basically making a table of values.

my problem is that i don't know how to use the input of the equation because it can only come in as a string.

any help/hints would be great.

Ask VB6 To Solve Equations
If you type in Text1.Text = 4+(6*8)+2^10-6 then VB6 will do the math for you. To make a calculator, can you just tell VB6 to solve whatever equation is in a textbox?

Building Equations
I am having a logic problem figuring out how I can allow my users to build equations by selecting points from a drop down and clicking add, sub, etc. etc. I can biuld simple equations with parenthases and basic math functions, but I need a Sum function and an avg function.

The user needs the ability to create an equation that calculates the cost/lb of product based on Raw Materials Cost/Lbs of production. But raw materials cost is the sumation of all the data items that belong to the cost group. The units are related to the data item, so I know whether it is dollars, lbs, metric tons or whatever.

What would your approach be? Your opinion is welcome.


The worst thing about wearing glasses is them being on your face.
Nothing is impossible, it just looks that way.

Mathematical Equations
hi! i have never worked with mathematical equations in vb, so i have no clue on where i could find info on how to do it.

all i need to do is to apply this formula:



Equations At Run Time

Is it possible to make VB execute an a function entered in runtime.

Example, I want to get the function(some thing like y=2*x* sin(x) ) from the user at run time and evaluate it.


Working With Mathematical Equations
I am working on a program that must display mathematical equations, just like in equation editor. the user may edit the contents of the control and save its contents in a database. is that possible? thanks

Storing Chemistry Equations
What would be the best way to go about storing a chemistry equation?
I am working on a chemistry program that will balance equations, find molar masses, etc.
In order to do this, I need to be able to store the equations in some kind of format using the atomic numbers (not the symbols). In the equation will be the products side, the reactants side, and each side will have multiple compounds. Each of the compounds will have the elements in them, their corresponding subscripts, and the symbolic equation of that compound stored in a string. I already have some form of storing equations, but I would like to know the most efficient method to store an equation using data structures or whatever.
Thanks for your help

Solving A Set Of Linear Equations
Hi all,

As part of an application I’m writing I need to solve a set of linear equations. The equations are in the form:
Where b is a vector of numbers x is the vector of unknowns and A is the matrix of coefficients.
The matrix A is big (may be 3000x3000), and spars. It is also close to singular but than is by the way….

As this is a classic problem I’m sure some one has done this before and there is no need for me to do it all over.
Does any one know of a *.dll or any thing else I could use to solve the problem.

Calculating String Equations
I have tried looking through various forums trying to find out if anyone knows how to calculate a value for and equation contained in a string eg "1 + 2 + 3" to make equal to 6
One of the forums suggested Microsoft's Script Control and use it's 'Eval' function to calculate it. Unfortunately when I try to run my program it crashes. I'm using VB 5 Control Creation Edn.
as it does not seam to get as close in VB 4 Professional. (Which I have. Does anyone have any suggestions on how to either fix it or any alternative.

Graphing Parametric Equations
I am graphing a fun looking parametric equation, but the value quickly becomes too high for the program. Neither the variable types Long or Double make any difference. I am trying to get the circle to stay a longer period of time before it clears itself out, but my loop doesnt work. Whats wrong?

Private Sub Command1_Click()
Dim t As Integer
Dim x As Long
Dim y As Long
Dim j As Integer

Do Until j = 100
For t = 1 To 1000
Let x = ((Sin(3 * t / 180)) * 1000) + 6000
Let y = ((Sin(4 * t / 180)) * 1000) + 4100
Command1.Move x, y
j = j + 1

Circle (x, y), 20, vbRed

Next t

Let Text1.Text = x
Let Text2.Text = y

End Sub


Private Sub Form_Load()
WindowState = 2
End Sub

Evaluating Math Equations
How can i get a vb prog to solve an equation placed in a text box.

Ihave tried to parse the text but the posibilities become endless.

Is vbscript the answer?


Math And Arangement Of Equations In VB
Hi All

Someone know how to calculate this arangement of equations through using methods of Gauss's and the result saving into a file text?

thanks in advance

Graphing Equations Using Excel
I'm in desperate need of help... I have a program here that is due later on in my programming class, and I feel very confident about a lot of my program, the only problem is that when I go to graph the equation, it sometimes draws extra lines. How do I fix this problem?

Displaying Equations On A Form
Hi All,

I need to display some equations on a form in VB (I will print the
result in a text box beside the equation).

The equations will in some cases be quite complicated and include
squares, fractions, powers, square roots, summations, greek characters

The question is: what is the best way to display these equations on
the form in a format of equal quality to that produced by the equation
editor in MS Word (say). In other words I want to lay out the equation
properly with all the right symbols etc, not just type the equation as
you would in the VB code and display it as a single line of

Do I need to position each character on the form separately to
build up the equation ? Do I need to generate it in another program and
display it as a graphic or is there a much easier and better way ?????

Thanks, any suggestions would be appreciated.


How Could You Display Complex Equations?
Does anyone know of a technique, or ActiveX control, that would enable a program to display equations in a "pretty print" style like a graphing calculator does? Ideally, I'm looking for something that can handle complex fractions, radical notation, superscripts, subscripts, etc... but I'd settle just for the complex fractions. Any help?

Polynomial Equations In Excel
Does anyone know how I can determine the slope of a 3rd order polynomial function using Excel VBA.

Thanks ever so much


Calculating System Of Linear Equations
Hi everyone. I have been working on a program to balance Chemistry Equations, what I have done is set up a system of linear equations in matrix form.

For an example, see the screenshot of some sample output from my program. I would like to know what is the best method to solve a system of linear equations.

The numbers in the table are the contents of my array, each number denotes how many elements are in that compound, each column is a different variable, and each row is already set equal to zero. Like for the first row in the picture an example equation would be 1*A + 0*B - 2*C - 0*D, each letter being the coefficient of each compound...sorry if I explained more than I had to.

Thanks for the help.

Solving Equations In Matrix Form
What I've got is 4 equations and 4 Unknowns. I'm moving a simulation from MatLab to VB6 to improve ease of use. Clearly you can't divide Matrices, but you can mulitply by the inverse.

ie AX = C solve for X,


Can this be done with matrices in VB? If so how? I've tried and get Complie Error Type Missmatch


Solving Equations (string Manipulation?)
I want to make a prog that graphs equations (like hyperbolas, parabolas, and everything else). How i do it is i get the equation (lets say "x^2-y^2=100"). Then i scroll through every X and Y value like this:

For X = XMin to XMax
For Y = YMin to YMax
next Y
next X

In the code i subsitute the numbers in for the variables so i might get something like this: "5^2-2^2=100"

So once i have that string, is there any easy way to solve it to see if the left side equals the right side (if it does, the prog plots a point at x,y). I know this is a very bad way to do it and it wont work with every equation, but im smart enough to make it better i just need to know how to solve that string. Any ideas/API?

Module/Code For Solving Equations
Does anyone have some code that could solve simple/complex equations like "2+(5/2)" if that was in a string? I'm trying to make a program that will graph equations like y^2 * x^2 = 25 and if i have some simple code like that to work off of it would be a whole lot easier.

Invert Matrix, Solve Equations.
Various people have asked me about inverting matrices and solving simultaneous linear equations. Instead of answering several people via email, I am posting what I know here.

There is some untested code further on. I apologize if there are typo’s or syntax errors. When I do not get paid for my work, I am less obsessive compulsive about avoiding errors.

I am sure that there are C programs available somewhere for solving linear equations and/or inverting matrices. I suspect that there are also programs written for various Basic dialects, but am not sure of this. While there are various methods applicable, a technique called Gauss Jordan elimination (or some similar name) is the most widely used. Perhaps a search of the web will turn up source code.

Many years ago I wrote Matrix software for various mainframes, using assembler and various compiler languages, but have never written such code for a PC. I can give you the general idea of the Gauss Jordan algorithm. I am pretty sure that this post is accurate, but cannot guarantee that my memory is 100% accurate. For a price, I would write and test a VB program.

I will use some VB code to describe the method, but warn the reader that this code is being made up as I create this post. It should not be viewed as tested code which is syntax perfect. For the benefit of those with little or no background, I will try to make it as simple as possible, which might bore or insult the intelligence of more knowledgeable readers.

First an overview of the method.The overall concept can best be understood by imagining an array with M rows and 2*M columns. The left half is a matrix to be inverted and the right half is an Identity matrix (All zeros except for main diagonal. Id est: A(X, X) = 1 for all X, with other elements equal to zero).If you systematically transform the left half into the Identity matrix and perform the same operations on the right half, the Identity matrix (right half) becomes the inverse of the original matrix. Some might find the following more confusing than the code to be shown later. Others might find the code harder to understand without the following description. For example: Start by dividing every element in the first row by the first element. This results in a value of one for the element in the upper left corner of the original matrix (left half of array) and the reciprocal of that element in the upper left corner of the original identity matrix (right half of array).Next: Multiply every element in the new first row by the first element in the second row, and subtract the products from the corresponding elements in the second row. Do the same for the third and all subsequent rows.The result of the above two operations is that the first column of the original Matrix looks like the first column of an Identity Matrix, and the first column of the original identity matrix no longer looks like an Identity matrix.Similar operations are performed to further transform the left half into an Identity matrix and the right half into the Inverse.

When coding the above, only an M by M array is used. Column by column, the Matrix is transformed into the inverse. Think about the above described operations which transformed the first column of the Matrix and the first column of the Identity matrix. It is known before doing calculations that the right half of the array is an Identity matrix. It is also known what the first column of the left half will look like after the first few operations: It will look like the first column of an Identity matrix. It is not necessary to actually store any columns which look like columns of an Identity matrix. Hence, only an M by M array is required for the program.

Another digression before showing some code. The Gauss Jordan elimination can also be used to solve simultaneous linear equations. A set of M such equations can be represented by an M by M matrix (coefficients of the unknowns) and a column of constant terms. Hence, an M by (M+1) array can represent a system of M linear equations in M unknowns. Similarly an M by (M+2) array can represent two such systems which have the same coefficients. If the operations which transform the matrix into the inverse are applied to the extra one (or more) columns originally containing constant terms, those extra columns will be transformed into solution vectors(s).

If it is only desired to obtain solution vectors, many of the inversion computations can be eliminated. After one set of operations, the first column of the matrix need not be processed. After two sets of operations, the first two columns need not be processed, and so forth.

One final digression before showing some code. The calculations require division, presenting the possibility of division by zero. The following code always uses a divisor from the main diagonal of the matrix, which is the simplest possible alternative. To avoid (if possible) division by zero and to improve precision, the correct algorithm analyzes the absolute value of potential divisors and chooses the largest possible divisor. This causes the resulting inverse and solution vectors to be scrambled, requiring some rearrangement of rows (and maybe columns) in the final array. The transform subroutine would not require any changes for off diagonal divisors, but the mainline which calls it would need modification. The mainline code shown is usable for most matrices.

A bit of jargon: The basic concept is a series of matrix transformations using pivot elements as divisors.

The following code is not a complete program, but indicates the basic computations and variables required.
Option Explicit
Public MatrixA() As Double 'Dynamic arrays to be dimensioned later.
Public WorkRow() As Double

Public MatrixSize As Integer 'Value supplied from external source
Public LastRow As Integer
Public LastColumn As Integer
Public X As Integer ‘Used in For loop

Public InvertMatrix As Boolean 'Assume these mutually exclusive
Public SolveEquations As Boolean 'Booleans initialized somehow.
Public DoBoth As Boolean
Public Junk As Integer
. . .
LastRow = MatrixSize - 1

If DoBoth Then
LastColumn = LastRow + 1 ‘Extra column for constant values
ElseIf InvertMatrix Then
LastColumn = LastRow ‘Square array
ElseIf SolveEquations Then
LastColumn = LastRow + 1 ‘Extra column for constant values
Junk = MsgBox ("There is big trouble here")
Junk = 5 / 0
End If

ReDim MatrixA(0 To LastRow, 0 To LastColumn) As Double
ReDim WorkRow(0 To LastColumn) As Double
. . . .
‘Some code required here to obtain values and put them into array.
. . .
For X = 0 To LastRow ‘This loop call subroutine to do the work.
If InvertMatrix Then
Call Transform(X, X, 0)
ElseIf SolveEquations Then
Call Transform(X, X, X)
ElseIf DoBoth Then
Call Transform(X, X, 0)
Junk = MsgBox("What happened?")
Junk = 5 / 0
Exit Sub
Next X
B]. . . .[/b]
‘Some code required here to display or pass results on for further processing.
. . .
Public Sub Transform(Row As Integer, Col As Integer, _
FirstColumn As Integer)
Dim J As Integer
Dim K As Integer
Dim PivotValue As Double
Dim RowMultiplier

PivotValue = MatrixA(Row, Col)

For J = FirstColumn To LastColumn
WorkRow(J) = MatrixA(Row, J) / PivotValue
Next J
'Following loop does some unnecessary work on Row
For J = 0 To LastRow
RowMultiplier = MatrixA(J, Col)

For K = 0 To LastColumn
MatrixA(J, K) = MatrixA(J, K) - RowMultiplier * WorkRow(K)
Next K

MatrixA(J, Col) = -RowMultiplier / PivotValue
Next J

For J = 0 To LastColumn
MatrixA(Row, J) = WorkRow(J)
Next J

MatrixA(Row, Col) = 1 / PivotValue

End Sub

Differential Equations And Graph Input In VB 6
Hi guys,

does anybody know, how to solve the differential equations in VB 6 and how to make a graph input and calculate the unknown x for example from the graph straight in vb press clicking the button? cheers

Resize Multiple Images But Ignore Equations
I have a doc with hundreds of images.
I want to build a VB script which will find them all, and will resize them.

The problem is that I also have hundreds of equations made on mathtype (like equation editor). I don't want them to be affected.
The code i've tried to use goes like

For each iShape InliseShapes bla bla
if iShape.Type=sthObject then ignore
else InlineShapes.Width=100
next iShape

My problem is that I don't know the exact jargon for sthObject -meaning equation. Any ideas/suggestions?
Obviously the above code isn't the only one can be used. If u have sth elese in mind glad to hear.

Thnx in advance

Help In Basic Air Data Equations/ Calculations In Excel
I have a couple of equations I need to figure out how to do in excel. But I dont know how to write them to use on the worksheet. I scaned the equations to jpeg but dont know how to post them to this form I dont know of any other way to have somebody take a look and see them to be able to help me.
If somebody will allow be to email the Jpeg tothem please let me know

How To Reveal Line Break For Perticuler Textbox In External Richtextbox/textbox?
Hi all could any one show me a method to identify the line break for perticuler richtextbox/textbox in external richtextbox/text. I am looking for things like this :<pbr>

I know all richtextbox/textboxes does not support that and some have thier own line break. could any one show me how to obtain that line break .thanks

class name info of rich edit :

My Window Class

Draw Textbox, Format Border And Type Text Into Textbox In A .doc File
I use this codes to open a .doc file and draw a textbox in it. What should I add to input text into the textbox (I used Selection.Text = "......." but the text are outside the textbox) and format it's borders?
[font=courier new][color=darkblue]
Private Sub Command1_Click()
Dim objWord As New Word.Application
Dim objDoc As Word.Document

objWord.DisplayAlerts = wdAlertsNone
Set objDoc = objWord.Documents.Add

objDoc.Shapes.AddTextbox msoTextOrientationHorizontal, 100, 100, 100, 300

objDoc.SaveAs "C:WINDOWSDesktoplabel.doc", wdFormatDocument


TextBox – How To Invoke ‘Command_Click()’ Upon Carriage Return Press In TextBox
Hi All,

I have a TextBox which I use to enter a serial number and a Command Button to execute a query to a database that takes the value entered in the TextBox.

How do I simulate the ‘Command_Click’ event upon Carriage Return press in the TextBox after entering the serial number? (saves the user having to press the command button using mouse)

Thanks in advance, Ash

Text Dissapears Form Textbox When I Tab Or Click Into Another Textbox
The title says it all really.

I enter text into txtName and then I want to enter text into txtInitial so I either tab to it or click into it and when I do the entry in txtName just dissapears.!!!???!!

I am setting textbox proerties at runtime...

With txtAddMemName
.Text = ""
.TabIndex = 0
End With
Make sure the textbox is empty....Text = ""
Set the TabIndex....TabIndex = 0 ....and so on
I have all the textbox properties in Private Sub TextBoxProperties() so that the form load section is easier to read.

Is that not right?

Retreiving The Pixel Contents Of A TextBox When Textbox Is Not Visible?
Is that possible? I need to get the contents of a textbox using StretchBlt, but this only works when the TextBox is visibly on screen, other wise I just get the contents of the screen where the textbox would be shown. How can I do this?

Passing Array Value In Textbox. The Textbox Turns Up Empty.
I am passing the value of an array to a textbox, but it always turns up empty. When i pass the same value to an excel cell, i get the value. The function calculates the value of USCityA

I am giving parts of the code below:
Redim Pline(9)
Pline(9) = USCityA
test = "Hello"
USA = test & Pline(9)

In another sub, i call this funtion above to allocate the value of USC to the city as shown below:

CityA = USA

Activesheet.OLEobjects("txtbCityA").Object.Value = "CityA:" & CityA

The value i get in my textbox is only "Hello". When i pass USA to an excel cell, i get "Hello Fortworth" (or whatever the value of "USA" is calculated in the function)

Textbox Ctl Right Justify Sends Text Too Far Out The The Textbox [SOLVED]
I have a newly made textbox control by Thief_ that I've modified and it works fine if Alignment is set to 0 - Left, but if set to 1 - Right Justify I have to type in several numbers before they start to appear from the right. How can I fix this? What property do I have to change / include in the control to control where the string begins when set to right justify?



Edited by - vbprog1144 on 5/30/2005 5:33:50 PM

Background Image In My Textbox Or Rich Textbox
I need to place a background image in a textbox or rich textbox as well. Is there no API or GDI(?) solution?

Background Image In My Textbox Or Rich Textbox
i would like to place a fixed background image in my textbox or rich textbox so it will act like a watermark. is that possible? please help.

i tried to use an rtf file template with image on it but everytime the rich textbox is updated the image is removed from view. i would like to remain on its position.

thank you very much. :P

Add Colored Text To Textbox Or Rich Textbox
Is there is script to make it add in a textbox the same text that is in the same text box plus some other colored text. eg



RichTextBox1.Text = RichTextBox1.Text + textFormated(&Hff,"lol")


RichTextBox1.Text = RichTextBox1.Text + textFormated(&Hff0000," test")

textlol test

Copyright © 2005-08, All rights reserved