문제

텍스트 영역과 구문을 강조 표시 할 기능이 있습니다. 지금은 전체 RichTextBox를 읽습니다. 현재 라인을 포함하는 문자열 변수를 어떻게 얻습니까? 아래는 내가 현재 가지고있는 코드입니다.

Private Sub HighLight()
    Dim rm As System.Text.RegularExpressions.MatchCollection
    Dim m As System.Text.RegularExpressions.Match
    Dim x As Integer ''lets remember where the text courser was before we mess with it

    For Each pass In FrmColors.lb1.Items
        x = rtbMain.SelectionStart
        rm = System.Text.RegularExpressions.Regex.Matches(LCase(rtbMain.Text), LCase(pass))
        For Each m In rm
            rtbMain.Select(m.Index, m.Length)
            rtbMain.SelectionColor = Color.Blue
        Next
        rtbMain.Select(x, 0)
        rtbMain.SelectionColor = Color.Black
    Next
End Sub
도움이 되었습니까?

해결책

시도하지 않고 :

rtbMain.Lines(lineNumber)

라인 속성을 배열에 할당하지 않고 배열 요소에 액세스하십시오.

다른 팁

나는 당신이 원한다고 생각합니다

rtbMain.Lines(rtbMain.GetLineFromCharIndex(rtbMain.SelectionStart))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top