Results 1 to 3 of 3

Thread: [RESOLVED] Simple yet important question

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Resolved [RESOLVED] Simple yet important question

    Hello everyone.

    I am currently working on my own "Colored textbox control" which inherits from the RichTextBox. What does the "Lines" property do? Does it generate the return array internally, or is it just passing back an array that is internally stored?

    E.g. I use this:
    Code:
        Public Sub SelectLines(ByVal lineindex As Integer, Optional ByVal linecount As Integer = 1)
            Dim lines() As String = Me.Lines
            If lineindex > lines.Count - 1 Then lineindex = lines.Count - 1
            If lineindex + linecount > lines.Count Then linecount = lines.Count - lineindex
    
            Dim selstart As Integer = 0
            Dim sellength As Integer = 0
            For i As Integer = 0 To lineindex + linecount - 1
                If i < lineindex Then selstart += lines(i).Length + 1 Else sellength += lines(i).Length + 1
            Next
            If sellength > 0 Then sellength -= 1
            Me.SelectionStart = selstart
            Me.SelectionLength = sellength
            Me.Focus()
        End Sub
    Can I skip the generation of "lines" and just use Me.Lines(i) etc. everywhere?

    The reason I ask is that I want to minimize the lag of the control, and I have to read all or a range of lines fairly commonly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width