Go to the line

comcrack

Well-known member
Joined
Jun 14, 2003
Messages
52
Location
Canada
Hy

Im triing to make an HTML,PHP,ASP editor for myself. In the menu Edit, I add the menu Go to the line . I try this code but it doesnt work. :

Code:
Private Sub MenuItem32_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem32.Click
        Dim temp As String
startMenuItem32:
        temp = InputBox("Quelle ligne?", "ComCrack(
 
Most programmers dont suggest using a goto statement in their code. Use while loop instead with continue instead of goto and break to exit the loop.
 
Its this line which doesnt work because It dont find the VBCRLF :
Code:
Text1.Find(vbCrLf, Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)


and I dont know why.
 
The method Find returns an integer. It does not look like you are assigning the value retured from it to anything. Maybe you are but I just dont know VB syntax very well.

It is not going to highlight the word for you. You must use the integer returned as an index number to highlight the word with some other method...
 
I tryed this :
Code:
Text1.SelectionStart = Text1.Find(vbCrLf, Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)

but an error say that I cant asign -1 to text1.selectionstart :

Additional information: -1 is not a valid value for value.

I think its because the find method doesnt find vbcrlf in my textbox
but there is many vbcrlf in the textbox.
 
You are going to have to split that up

int i=Text1.Find(vbCrLf, Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)
if(i not equal to -1)
Text1.SelectionStart = i

What is vbcrlf?
 
Your best bet for finding anything in a string is to use class Regex.
Here is a C# example:
C#:
public static MatchCollection FindExact(string text, string find)
{
	MatchCollection mc = Regex.Matches(text, @"\W" + "(?<G>" + find + ")" + @"\W");
	return mc;
}
But if you are just looking for new line characters just use IndexOf of the string class.
 
I tryed to do this and it work :
Code:
Text1.SelectionStart = Text1.Find("salut",Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)

after I tryed this but it doesnt work. It did the same error

Code:
Text1.SelectionStart = Text1.Find(chr(10),Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)
 
I found some thing other whit split like you say:


[VB]
Dim temp As String
startMenuItem32:
temp = InputBox("Quelle ligne?", "ComCrack(
 
Back
Top