[RESOLVED] How to get x number of characters after a string?
Say I open a text file in a richtextbox control. After that I search for a specific string like "6.1". The string actually continues like "6.1XXXXXXX". I need to get not just only "6.1", but also 2 more chars after "6.1", like "6.1XX". i will then output this in a textbox, but i can do that, I don't know how to get the X number of characters, any help or idea with that?
Re: How to get x number of characters after a string?
try this:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim findString As String = "6.1"
TextBox1.Text = RichTextBox1.Text.Substring(RichTextBox1.Text.IndexOf(findString), findString.Length + 2)
End Sub
Re: How to get x number of characters after a string?
Quote:
Originally Posted by
.paul.
try this:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim findString As String = "6.1"
TextBox1.Text = RichTextBox1.Text.Substring(RichTextBox1.Text.IndexOf(findString), findString.Length + 2)
End Sub
THANK YOU sooooo much, you have helped me a lot with this one, you can call this thread resolved now! Once again, thanks!
Re: How to get x number of characters after a string?
Quote:
Originally Posted by
Legjendat
you can call this thread resolved now!
Or you can, using the Thread Tools menu. :)
Re: How to get x number of characters after a string?
Quote:
Originally Posted by
jmcilhinney
Or you can, using the Thread Tools menu. :)
My bad, sorry, never had a thread resolved till now, this was the first one so I didn't know I could call it resolved myself, done now!