Sep 19, 2009
I've to make a program that reads an arithmetical sentence from a textbox, e.g 12.3*34+4*5-3 and then on another textbox identify and display what is the content of the first textbox, for example taking the last ex:
View 2 Replies
If I have this input:
The output should look like this:
This program should only read this operators like (+,-,*,/).I'm have in mind 2 ways of doing it, one with regex and the other taking the first sentence, put it on an array, then trim it, and somehow get the values of the array and identify if it is a number or a decimal number and if it's an operator and then display it.
The difficult part or the part that i can't conceptualize is how to implement it with regex (it should be easier with a regex format than storing it on a array).I write a bit of code, I used an array to store and then to print the numbers and I used the split function to separate the math operator, but I dunno how to print the operators and the tags.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Sentencia As String = TextBox1.Text Dim i As Integer Dim arryTextBox() As String TextBox2.Clear() arryTextBox = Sentencia.Split("+", "-", "*", "/") For i = 0 To UBound(arryTextBox) Dim Array As String = arryTextBox(i)
Btw, I also have the code to validate the input on the textbox ::wink::