# Math equation output

• ### Question

• Hi guys! I'm new to VB and also new to this forum. My first question is: is there any way to generate a report by VB codes to display  math equations like what we can do in Word by using Equation Editor? Thanks!
Saturday, August 11, 2007 4:29 AM

• Hi Danie,

According to your specific requirement, I believe I find a good solution inside the following article.

Enable Your Users To Write Math Equations In Your Web And Desktop Apps

This article shows how to type mathematical equations in popular TeX format and render them as GIF images in your web and desktop applications by third-party component called MimeTeX Win32 DLL.

You can register and download source code and some demoes including that MimeTeX.dll, then look into one sample WinForms app in Eq2ImgWinForms folder. When I type sqrt(x^2+xy+y^2) in the textbox, the right math equalation will be rendered on the Picturebox control, and the Square Root mark can expand or shrink based on the length of the characters underneath.

You can use this code in three ways.

1. Use in desktop apps

This is pretty easy. You just need to DLLImport MimeTex.DLL and call CreateGifForEq function from your Win Forms app like this:

[System.Runtime.InteropServices.DllImport("MimeTex.dll")]
internal static extern int CreateGifFromEq(string expr, string fileName);

2. Integrate with your own web apps

Download the code, add the files in the folder named OnlyRequiredFiles (For VB.NET, look under the VB.NET Version folder) into your ASP.NET project and drop the MimeTex.DLL in bin folder. Edit your default.aspx page and put this line somewhere in Page_Load or Page_Init.

 3. Use as a separate web app Copy Eq2Img folder in your wwwroot. Create a virtual folder, make sure the CachedEqImages folder exists and ASP.NET user has write permissions for it, and default.aspx is configured as the default page. 

Here are other references.

This article describes how to use CodeDom and Reflection to Create a Calculator that can evaluate simple and complex math expressions.

Regards,

Martin

Thursday, August 16, 2007 2:05 PM

### All replies

• Hi Danie,

Yes, you can display math equalations and print them in VB code.

Here is a good sample including illustrations and code.

Math Equation Editor in VB.NET

This article explains about the Math Equation Editor in VB.NET. The Equation Editor created in VB.NET allows you to create a few simple equations using the keyboard. The editor also allows you to print your equations to the printer or save the equations to a bitmap to insert into a Word or HTML document.

By the way, here is C# version.

Math Equation Editor in C#

Regards,

Martin Xie

Tuesday, August 14, 2007 2:05 AM
• Thanks martin, your answer is really helpful. But I wanna make it even better. You know the equation editor attached to Word, the sqrt mark can expand or shrink based on the size of the characters underneath. Is there any third party classes or subroutines we can call from inside our own codes?

Tuesday, August 14, 2007 8:27 PM
• Hi Danie,

According to your specific requirement, I believe I find a good solution inside the following article.

Enable Your Users To Write Math Equations In Your Web And Desktop Apps

This article shows how to type mathematical equations in popular TeX format and render them as GIF images in your web and desktop applications by third-party component called MimeTeX Win32 DLL.

You can register and download source code and some demoes including that MimeTeX.dll, then look into one sample WinForms app in Eq2ImgWinForms folder. When I type sqrt(x^2+xy+y^2) in the textbox, the right math equalation will be rendered on the Picturebox control, and the Square Root mark can expand or shrink based on the length of the characters underneath.

You can use this code in three ways.

1. Use in desktop apps

This is pretty easy. You just need to DLLImport MimeTex.DLL and call CreateGifForEq function from your Win Forms app like this:

[System.Runtime.InteropServices.DllImport("MimeTex.dll")]
internal static extern int CreateGifFromEq(string expr, string fileName);

2. Integrate with your own web apps

Download the code, add the files in the folder named OnlyRequiredFiles (For VB.NET, look under the VB.NET Version folder) into your ASP.NET project and drop the MimeTex.DLL in bin folder. Edit your default.aspx page and put this line somewhere in Page_Load or Page_Init.

 3. Use as a separate web app Copy Eq2Img folder in your wwwroot. Create a virtual folder, make sure the CachedEqImages folder exists and ASP.NET user has write permissions for it, and default.aspx is configured as the default page. 

Here are other references.

This article describes how to use CodeDom and Reflection to Create a Calculator that can evaluate simple and complex math expressions.

Regards,

Martin

Thursday, August 16, 2007 2:05 PM
• Thank you so much Martin!
Thursday, April 17, 2008 7:00 PM
• Hi,

I know this thread is complete an Martins advice answers everything spot on but I'd just like to direct you towards something called MathML. Only know a little about it but it's a way to represent equations using XML. This can be rendered to a browser with a plugin. This is all I know, perhaps it might be of interest.

Friday, April 18, 2008 8:20 AM
• hi sir

help me
Monday, July 20, 2009 11:48 AM
• thanks

where is register for that dll. then i will getting full support.
how much cost.

• Merged by Tuesday, July 21, 2009 7:19 AM Merge it to keep them in the same topic.
Monday, July 20, 2009 11:57 AM
• Thank you, Omie.
Monday, July 20, 2009 12:29 PM
• hi sir

Welcome to MSDN forums!

As I mentioned in my previous post, you need to download it from this CodeProject article:
Enable Your Users To Write Math Equations In Your Web And Desktop Apps

Walkthrough:
1. Register you in http://www.codeproject.com/ and login in.
2. Go to the above article, Download source code and Windows Forms demo - 1.94 MB (named Eq2Img_all.zip)
3. Unzip the Eq2Img_all.zip file, then trach this path to find the "MimeTex.dll": Eq2Img_all\Eq2ImgWinForms\Eq2ImgWinForms\bin\Debug\MimeTeX.dll

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Tuesday, July 21, 2009 1:08 AM
• thanks

where is register for that dll. then i will getting full support.
how much cost.

The MimeTex.dll is free and source-open.
Follow the CodeProject article and demo inside for detailed instruction, and contact the article author for full support.
Enable Your Users To Write Math Equations In Your Web And Desktop Apps

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Tuesday, July 21, 2009 7:27 AM

• Hi Martin,

But,I have some problems.....
I am trying to make it more user friendly.Instead of making user remember so many notations for symbole like "\sqrt","\frac" etc......So, I am making a toolbox on my form for all symbols.Suppose, user clicks on squareroot sign button , then in the textbox there should appear "sqrt(,) "  and inside bracket user can enter value accordingly and in backend "\sqrt" should run itself and display the result accordingly.
Neither I want to show the "TeX" format to user,In the textbox I want to display such format that is easily understandable by the user.
I mean to say I don't want user to remember notations for symbols.On whatever button he clicks ,the corresponding TeX script should run in backend code and result displays accordingly..............
how can I do this...

Kindly help me out............

Thursday, August 27, 2009 9:08 AM
• Hello Martin Xie - MSFT & Avirag,

I am also working on the Equations in asp.net. I have gone through that codeproject article from Shital Shah and ASCIIMathML.

Unfortunetly I am not able to run the codeproject.com's application. It gives me error that Mimetex.DLL is not loaded. Although its there in Bin directory. Can anyone send me some working application of that?

Avirag If you have working code can you guide me on that? I am also in process of developing the Interface with images to ease the entering.

Girish
Wednesday, September 2, 2009 2:49 PM
• Hello Martin Xie - MSFT & Avirag,

I am also working on the Equations in asp.net. I have gone through that codeproject article from Shital Shah and ASCIIMathML.

Unfortunetly I am not able to run the codeproject.com's application. It gives me error that Mimetex.DLL is not loaded. Although its there in Bin directory. Can anyone send me some working application of that?

Avirag If you have working code can you guide me on that? I am also in process of developing the Interface with images to ease the entering.

Girish
• Proposed as answer by Friday, September 18, 2009 1:21 PM
Wednesday, September 2, 2009 2:50 PM
• hi Girish,

click on this link : http://www.codeproject.com/KB/dotnet/Eq2Img.aspx
and download the project.unzip it and open " Eq2ImgWinForms" file in visual studio.
Try it again ,its running absolutely  fine ............

Friday, September 18, 2009 1:26 PM
• Hello Avirag,

The Win application working fine. I got it working in asp.net too. but the problem is I have to keep MimeTex.DLL in C:\Windows\System32 directory otherwise it throws exception: unable to load the DLL.

One more thing, we need to put the Default.aspx and classes, handlers in all sub directories wherever we are using the equations. I think the web handler is coded as such.

I am working on it.

If you find something useful about that. Please mail me on girish128@gmail.com

Thanks & Regards,

Girish
Saturday, September 19, 2009 8:51 AM
• Hello My problem is almost the same I could user in textbox, webpage to type mathematical equations If you arrived at the answer to my email Please mahdyhe.karami1987@gmail.com Thank
Thursday, June 3, 2010 9:35 AM
• It is never "codes". It is always, "code".

Renee

Thursday, June 3, 2010 3:07 PM
• Hello My problem is almost the same I could user in textbox, webpage to type mathematical equations If you arrived at the answer to my email *********************** Thank

The answer is posted above.  I suggest that you remove your email before you get spammed by some internet bot.

Mark the best replies as answers. "Fooling computers since 1971."
Thursday, June 3, 2010 3:41 PM