Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 1 decade ago

vb6要如何讀取游標目前的行數?

如題

我只會讀出整個Text1的總行數

可是我不知道該怎麼讀出游標目前所在的位置

希望可以在Text1_Change()裡做計算

拜託各位大大了!!!

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    我可以寫出在 Text1_KeyUp 下的

    至於 Text1_Change 那就沒辦法啦

    Option Explicit

    Private Sub Form_Load()

    Text1.Text = ""

    End Sub

    Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)

    Dim t() As String, Left_t As String

    t = Split(Text1.Text, Chr(13))

    Select Case KeyCode

    Case 37, 39, 8, 46, 13, 38, 40

    If Text1.SelStart >= 1 Then

    Left_t = Left(Text1.Text, Text1.SelStart)

    t = Split(Left_t, Chr(13))

    Label1.Caption = UBound(t) + 1

    Else

    Label1.Caption = 1

    End If

    End Select

    End Sub

    Source(s): 自己
  • W.J.S.
    Lv 7
    1 decade ago

    查一下SelStart屬性

Still have questions? Get your answers by asking now.