Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal dwMessage As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINEFROMCHAR = &HC9
Private Sub Form_Load()
Me.Label2(0).Caption = ""
Me.Label2(1).Caption = ""
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Dim rc, cnt
If KeyCode = vbKeyUp Or KeyCode = vbKeyDown Or vbKeyReturn Then
cnt = SendMessage(Me.Text1.hWnd, EM_GETLINECOUNT, -1, 0)
rc = SendMessage(Me.Text1.hWnd, EM_LINEFROMCHAR, -1, 0) + 1
Me.Label2(0).Caption = rc & " / " & cnt & "行目"
End If
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
cnt = SendMessage(Me.Text1.hWnd, EM_GETLINECOUNT, -1, 0)
rc = SendMessage(Me.Text1.hWnd, EM_LINEFROMCHAR, -1, 0) + 1
Me.Label2(0).Caption = rc & " / " & cnt & "行目"
End Sub |