CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2012
    Posts
    2

    how to get the al information from the brackets of each sin()

    hi , I am pradeep.
    i wrote a code to get all information with in brackets of each sin() ,which i would like to give as my input to text box.
    but i am not able to get it exactly,
    for example i write "sin(90*2)+sin(60)+sin(60+(75*2))+sin(50)+sin(20)" in textbox
    i need "90*2,60,60+(75*2),50,20" as my out put
    here is my code what i wrote ,please modify my code and help me


    Code:
    public class form1 
       Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button25.Click
          Dim j As Integer = 0
          Dim startPos As Integer
    
          Dim parenCount As Integer = 1
          Dim innerLen As Integer = 0
          For j = 0 To TextBox1.Text.Length - 1
             startPos = TextBox1.Text.IndexOf("sin(", j) + 4
             For i As Integer = startPos To TextBox1.Text.Length
    
                If TextBox1.Text(i) = "("c Then
                   parenCount = parenCount + 1
                End If
    
                If TextBox1.Text(i) = ")"c Then
                   parenCount = parenCount - 1
                End If
    
                If parenCount = 0 Then
                   Exit For
                End If
                innerLen = innerLen + 1
    
             Next i
             MsgBox(TextBox1.Text.Substring(startPos, innerLen))
          Next j
       End Sub
    end class

    please help me
    thanks in advance
    Last edited by Cimperiali; January 30th, 2012 at 05:43 PM. Reason: added code tags and indention

  2. #2
    Join Date
    Jan 2012
    Posts
    2

    Re: how to get the al information from the brackets of each sin()

    please help me its urgent

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: how to get the al information from the brackets of each sin()

    A few String.Replace() should work. Get rid of SIN, and the () for each, and add a . after each one
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured