⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtftextgoto.bas

📁 VBScriptcomplier希望大家喜欢。
💻 BAS
字号:
Attribute VB_Name = "Module0"



Public Sub SetCursorAtLine(WhichLine As Long, WhichRTFText As RichTextBox)

Dim Estimate As Long, StartP As Long, EndP As Long
Dim NumChars As Long



With WhichRTFText

    NumChars = Len(.Text)

   
    If NumChars = 0 Then
        Exit Sub
    End If
    
    If WhichLine <= 1 Then
        .SelStart = 0
        .SelLength = 0
        Exit Sub
    ElseIf WhichLine > (.GetLineFromChar(NumChars) + 1) Then
        .SelStart = NumChars
        .SelLength = 0
        Exit Sub
    End If
        
    Estimate = Int(NumChars / 2)
    StartP = 1
    EndP = NumChars

    Dim Finalised As Long
    Do
        If WhichLine < (.GetLineFromChar(Estimate) + 1) Then
     
            StartP = StartP
            EndP = Estimate
            Estimate = StartP + Int((EndP - StartP) / 2)
        ElseIf WhichLine > (.GetLineFromChar(Estimate) + 1) Then
 
            StartP = Estimate
            EndP = EndP
            Estimate = StartP + Int((EndP - StartP) / 2)
        Else
            Finalised = Estimate
   
            Do
                Finalised = Finalised - 1
                If Finalised = 0 Then
                
                    .SelStart = Finalised
                    .SelLength = 0
                    Exit Do
                Else
                    If (.GetLineFromChar(Finalised) + 1) < WhichLine Then
                        Finalised = Finalised + 1
                        .SelStart = Finalised
                        .SelLength = 0
                        Exit Do
                    End If
                End If
            Loop
            Exit Do
        End If
    Loop
End With
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -