| | |
Math output
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
vinnijan,
You really need to try to figure this out. The code works but you implemented it incorrectly. You're not even trying to learn what the code does but rather seeing the code does not fit your solution as-is then posting back here with another question.
Make this change:
You really need to try to figure this out. The code works but you implemented it incorrectly. You're not even trying to learn what the code does but rather seeing the code does not fit your solution as-is then posting back here with another question.
Make this change:
C# Syntax (Toggle Plain Text)
//const string txtBoxInput = @"()/()"; string txtBoxInput = textBoxEquation.Text;
•
•
Join Date: Jul 2009
Posts: 126
Reputation:
Solved Threads: 10
here I have attested the thumbnail of my output , in which its showing bracket and not the fraction form which we see in books.
Actually when I am entering bracket format in textbox which is user friendly but in math format output I want the fraction form which we see in books.
In textbox I want bracket only but in math format I want it in actual fraction like in books.
Kindly give me some solution..........
Actually when I am entering bracket format in textbox which is user friendly but in math format output I want the fraction form which we see in books.
In textbox I want bracket only but in math format I want it in actual fraction like in books.
Kindly give me some solution..........
Vinnijain,
Here at Daniweb we have a policy of helping those who help themselves.
sknake has now given you all the code you need to take the input fromthe textbox and convert it to a latex format string:
Learning to code involves experimenting with new concepts. You have been shown everything you need to do to solve your problem, now you need to examine the code you have been given, work out what it is doing and apply that to your solution.
We are happy to help, but the only way your coding will move forward is if you take the time to understand each aspect of the project
Here at Daniweb we have a policy of helping those who help themselves.
sknake has now given you all the code you need to take the input fromthe textbox and convert it to a latex format string:
C# Syntax (Toggle Plain Text)
const string matchNumerator = @"\((?<Numerator>[\d,]*(\.\d*))\)"; const string matchDenominator = @"\((?<Denominator>[\d,]*(\.\d*))\)"; const string matchBoth = matchNumerator + @"\/" + matchDenominator; //Here is the change he told you to make //const string txtBoxInput = @"()/()"; string txtBoxInput = textBoxEquation.Text; System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(txtBoxInput, matchBoth); if (m.Success) { decimal dNumerator, dDenominator; if (decimal.TryParse(m.Groups["Numerator"].Value, out dNumerator) && decimal.TryParse(m.Groups["Denominator"].Value, out dDenominator)) { //and this right here is your string in latex format string latex = @"\frac {" + dNumerator.ToString() + "}{" + dDenominator.ToString() + "}"; decimal valueOut = dNumerator / dDenominator; System.Diagnostics.Debugger.Break(); }
Learning to code involves experimenting with new concepts. You have been shown everything you need to do to solve your problem, now you need to examine the code you have been given, work out what it is doing and apply that to your solution.
We are happy to help, but the only way your coding will move forward is if you take the time to understand each aspect of the project
Last edited by Ryshad; Oct 2nd, 2009 at 8:13 am.
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Im not sure i understand what you need a hint with?
I made the changes that sknake gave you and put it all together into the code in my last post. That code will take the text from the textbox, locate "(number1)/(number2)" and convert it into "\frac {number1}{number2}" stored in the variable called latex.
Isnt that what your question required?
I made the changes that sknake gave you and put it all together into the code in my last post. That code will take the text from the textbox, locate "(number1)/(number2)" and convert it into "\frac {number1}{number2}" stored in the variable called latex.
Isnt that what your question required?
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
•
•
Join Date: Jul 2009
Posts: 126
Reputation:
Solved Threads: 10
Ryshad,
The code which I am using is as follows: Since I have made for all mathematical symbols and the mathematical equation can be the combination of any symbol.So when we click on any of the math symbol ,it is appended in the textbox.So,when i am using :
It means complete textbox string is assigned to txtBoxInput.
So how can I get fraction value for this "()/()" when its being used with other math symbols too..........
If I would be inserting only "()/()" in textbox it will generate equivalent fraction but not when its being used with other symbols too.........
I want the output as seen in the attached thumbnail
i think you understand what I am trying to say..........
The code which I am using is as follows:
C# Syntax (Toggle Plain Text)
textBoxEquation.AppendText("()/()"); this.textBoxEquation.Focus(); const string matchNumerator = @"\((?<Numerator>[\d,]*(\.\d*))\)"; const string matchDenominator = @"\((?<Denominator>[\d,]*(\.\d*))\)"; const string matchBoth = matchNumerator + @"\/" + matchDenominator; //Here is the change he told you to make //const string txtBoxInput = @"()/()"; string txtBoxInput = textBoxEquation.Text; System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(txtBoxInput, matchBoth); if (m.Success) { decimal dNumerator, dDenominator; if (decimal.TryParse(m.Groups["Numerator"].Value, out dNumerator) && decimal.TryParse(m.Groups["Denominator"].Value, out dDenominator)) { //and this right here is your string in latex format string latex = @"\frac {" + dNumerator.ToString() + "}{" + dDenominator.ToString() + "}"; decimal valueOut = dNumerator / dDenominator; System.Diagnostics.Debugger.Break(); } }
C# Syntax (Toggle Plain Text)
string txtBoxInput = textBoxEquation.Text;
So how can I get fraction value for this "()/()" when its being used with other math symbols too..........
If I would be inserting only "()/()" in textbox it will generate equivalent fraction but not when its being used with other symbols too.........
I want the output as seen in the attached thumbnail
i think you understand what I am trying to say..........
Last edited by vinnijain; Oct 2nd, 2009 at 9:42 am.
If im not mistaken you are placing that code inside the event handler for the "÷" button. You only need to parse the data using this code when you update the equation image.
The code you have been given will match a single instance of ()/() in the string and convert it. You need to modify it to find multiple instances. You will also need to modify the Regular Expressions to match other kinds of symbols. The links i gave you originally will have all the info you need on writing your own regular expressions.
The code you have been given will match a single instance of ()/() in the string and convert it. You need to modify it to find multiple instances. You will also need to modify the Regular Expressions to match other kinds of symbols. The links i gave you originally will have all the info you need on writing your own regular expressions.
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
•
•
Join Date: Jul 2009
Posts: 126
Reputation:
Solved Threads: 10
•
•
•
•
If im not mistaken you are placing that code inside the event handler for the "÷" button. You only need to parse the data using this code when you update the equation image.
The code you have been given will match a single instance of ()/() in the string and convert it. You need to modify it to find multiple instances. You will also need to modify the Regular Expressions to match other kinds of symbols. The links i gave you originally will have all the info you need on writing your own regular expressions.
C# Syntax (Toggle Plain Text)
private void button3_Click(object sender, EventArgs e) { textBoxEquation.AppendText("÷"); this.textBoxEquation.Focus(); } private void textBoxEquation_TextChanged(object sender, System.EventArgs e) { WriteEquation(FormatText(textBoxEquation.Text)); } private string FormatText(string input) { input = input.Replace("÷", "\\div"); input = input.Replace("π", "\\pi"); input = input.Replace("θ", "\\theta"); input = input.Replace("∞", "\\infty"); return input; }
Also I want to ask you that when you executed the code ,you were getting the equivalent fraction the values in bracket format?Because I was not getting fraction format as in thumbnail.
Last edited by vinnijain; Oct 2nd, 2009 at 10:11 am.
![]() |
Similar Threads
- how to use regex or an array to display some output from an arithmetic input? (VB.NET)
- Trouble with area (Java)
- math help (PHP)
- math program (C)
- Math.max prob???...XD (Java)
- So Stuck (C++)
- Assigning Array Values En Masse (Java)
- Output in Text file-How to apply fprintf()? (C)
- Output in the text file (C)
- missing function header (C++)
Other Threads in the C# Forum
- Previous Thread: How to generate button at runtime and its text from database for windows application
- Next Thread: password setting in a software
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees delegate development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick movingimage mysql networking operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer transparency treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






