this is pradeep, i m vb.net learner,my English not good dont mind
what i need is i what to get all information within the parenthesis of Sin().
for example , i have created one one textbox in my user interface.
i wanted users to enter some trigonometric expresiions like " sin(90+(25+25))"
for that i what all the information present with in the parenthesis of sin()
can anyone give the code to help me
thanks in advance

Recommended Answers

All 5 Replies

if user enters "sin(90+(25*2))+sin(45+(25*2))"
how can i get "90+(25*2)" and "45+(25*2)"
please help me.thank you for your reply

you will have to parse the line yourself I think. check out the instr, and mid$ functions. The presence of a second set of brackets is going to make it tricky. have a think about the logic and post what you come up with.

Private Function GetMid(somestring As String) As String
Dim startPos As Integer = somestring.IndexOf("sin(") + 4

Dim parenCount As Integer = 1
Dim innerLen As Integer = 0

For i As Integer = startPos To somestring.Length

If somestring(i) = "("c Then
parenCount += 1
End If

If somestring(i) = ")"c Then
parenCount -= 1
End If

If parenCount = 0 Then
Exit For
End If

innerLen += 1

Return somestring.Substring(startPos, innerLen)
End Function

the above code is when textbox has only one sin() function,how to get if more than one sin() present in textbox??

How are these sins:D present in the TextBox?
1 sin per each line?:D
2 or more sins per line?:D
Or is it just a TextBox full of sins?:D with no hope of ever going to heaven.LMAOOO:D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.