Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hy

 

I'm 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 doesn't work. :

 

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(Éditeur)")
       If temp = "" Then
           Exit Sub
       ElseIf Not IsNumeric(temp) Then
           MsgBox("La valeur n'est pas numérique.", MsgBoxStyle.Critical, "ComCrack(Éditeur)")
           GoTo startMenuItem32
       ElseIf Not Int(temp) = temp Then
           MsgBox("La valeur n'est pas numérique.", MsgBoxStyle.Critical, "ComCrack(Éditeur)")
           GoTo startMenuItem32
       End If
       Text1.SelectionStart = 0
       Dim i As Integer
       For i = 1 To temp
           Text1.Find(vbCrLf, Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)
       Next

 

Thank you

 

ComCrack

[ () /\/\ [ |\ /\ [ |<
Posted

It's this line which doesn't work because It don't find the VBCRLF :

Text1.Find(vbCrLf, Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)

 

 

and I don't know why.

[ () /\/\ [ |\ /\ [ |<
Posted

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 don't 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...

C#
Posted

I tryed this :

Text1.SelectionStart = Text1.Find(vbCrLf, Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)

 

but an error say that I can't asign -1 to text1.selectionstart :

 

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

 

I think it's because the find method doesn't find vbcrlf in my textbox

but there is many vbcrlf in the textbox.

[ () /\/\ [ |\ /\ [ |<
Posted

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?

C#
Posted

Your best bet for finding anything in a string is to use class Regex.

Here is a C# example:

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.

C#
Posted

I tryed to do this and it work :

Text1.SelectionStart = Text1.Find("salut",Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)

 

after I tryed this but it doesn't work. It did the same error

 

Text1.SelectionStart = Text1.Find(chr(10),Text1.SelectionStart + 1, RichTextBoxFinds.MatchCase)

[ () /\/\ [ |\ /\ [ |<
Posted

I found some thing other whit split like you say:

 

 

       Dim temp As String
startMenuItem32:
       temp = InputBox("Quelle ligne?", "ComCrack(Éditeur)")
       If temp = "" Then
           Exit Sub
       ElseIf Not IsNumeric(temp) Then
           MsgBox("La valeur n'est pas numérique.", MsgBoxStyle.Critical, "ComCrack(Éditeur)")
           GoTo startMenuItem32
       ElseIf Not Int(temp) = temp Then
           MsgBox("La valeur n'est pas numérique.", MsgBoxStyle.Critical, "ComCrack(Éditeur)")
           GoTo startMenuItem32
       End If
       Text1.SelectionStart = 0
       Dim i As Integer
       Dim temparray() As String
       temparray = Split(Text1.Text, Chr(10))
       Dim temptextlen As Integer = 0
       If Not temp - 1 > UBound(temparray) Then
           For i = 1 To temp - 1
               temptextlen = temptextlen + 1 + Len(temparray(i - 1))
           Next
           Text1.SelectionStart = temptextlen
       End If

It work!!!!!!!!!!!!!!!!!!!!!

 

Thanks a lot

 

ComCrack

[ () /\/\ [ |\ /\ [ |<

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...