search string and return the following six characters.

How would I best click a button and display the six characters that follow a specific part in a string. i would like to display in a label.

for example search the above state ment for "button and " then return "display" to a label in the form.

Thanks in advance!!



Answer this question

search string and return the following six characters.

  • Stephen J.Vanterpool

    how do I use the string as a label
  • kweicht

    Yes, Thank you this helps, Two more issues, how do I get the core to return the not text AFTER not including. For example above return "button and display to an from and blah blah". How do I get just "display to an from and blah blah"

    also how do I erase everything after a certain point in the string


  • migz148

    when i enter text the first time and click the button it works ok, but with I change the text and click the button for a different result. it freezes
  • newcyan

    sorry how exactly do you mean do you mean showing a string on a label

    Me.theLabelControl.Text = "some string"

    of course replacing the variable name of the control...



  • Cordell Swannack

    no errors just freezes
  • Jalf

    Do you get any errors what are they



  • Dee_dotnet_79

    System.Security.SecurityException was unhandled
    Message="Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

  • PraveenL

    I trying to convert a string into a double, can anyone help

    Dim number As String = myString.Substring(myString.IndexOf("ET: </small><big><b>") + 20)

    number = Quote.Remove(Quote.IndexOf(".") + 3)

    Dim Open As String = myString.Substring(myString.IndexOf("Open:</td><td class=""yfnc_tabledata1"">") + 38)

    Open = Open.Remove(Quote.IndexOf(".") + 3)

    Dim Open2 As Double

    Open2 = CDbl("Open")

    Dim number2 As Double

    number2 = CDbl("number")


  • CPPUSer7

    Glad I could help! :-)

    if its a double quote (open speech mark) then use 2 of them:

     

    ""Hello""

    would return "Hello" (including the quotes). Example:

     



    Dim theString as new String = "hello my name is ""Bob"""
    MessageBox.Show(theString)

     

     

    Should show:

     

    hello my name is "Bob"

    Since the quote is a string indicator for VB (and C#, probably most languages), when you place another quote, it will assume (like most languages) that the string has been completed/closed off so if you place 2 quotes next to each other, it will "escape" that out

    does this help



  • ttad

    well in the example, this is what it does, it will give you all the text after "button and" returning "display to and from and blah blah"

    To remove everything after a certain point in the string, you can either:

  • select the text you only want (again using substring) (probably the easiest solution)

  • use the "Remove" method:

     



  • Dim theString as new String = "hello I need to be removed..."
    theString = theString.Remove(theString.IndexOf("hello"))

     

     

    this will remove everything after the text "hello" and store it back into the "theString" variable, since it returns back a string

     

    does this help

     



  • Luis Esteban Valencia Mu&amp;#241;oz

    you can either use Regex (regular expressions) as they are powerful and do good pattern searching but can be expensive (resources etc...) and may not be ideal for your situation.

    you can use some of the string functions like someString.SubString(0) etc...

     

    now to obtain all text/string after a specific position:

     

    dim myString as String = "button and display to an from and blah blah"

    dim theRestOfString as String = myString.SubString(myString.indexOf("button and"))

     

    this should return back all text after it finds the first occurance of "button and"

     

  • Substring is a method which returns back a string after a specified position or can retrieve the string FROM a specified position TO a specified position within another string

  • indexOf is a method which gets the position of the first occurance of the string given

     

    does this help



  • paso

    string into double:

     



    Dim theDoubleValue as Double
    if Double.TryParse(StringValue, theDoubleValue) = True then
       'Successful conversion, the value will now be stored in theDoubleValue
    end if

     

     

    TryParse will do exactly as it says, it will try to parse the string variable given into a double, storing the result in the double parameter given "theDoubleValue" if it succeeds

     

    does this help



  • Milzit

    Does anyone know why I click the button and this works the first time but freezes the second time

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    Dim myString As String = TextBox4.Text

    Dim CompanyName As String = myString.Substring(myString.IndexOf("class=""ygtb""><b>") + 16)

    CompanyName = CompanyName.Remove(CompanyName.IndexOf("(") - 1)

    Label4.Text = CompanyName

    End Sub


  • Ganeshkumar S

    Yes that works! I actually had just figured that out on my own ,amazingly enough, Thanks

    However my next issue is that I have " in the string I am now looking for. any ideas


  • search string and return the following six characters.