RICH TEXT

GABRIEL.LOGAN 28/02/2005 20:00:53
#70416
Alguem sabe como enumero cada linha de um rich ou text box?

Exemplo:

1 gabriel
2 fulano
3 ciclano
4 alguem

E assim por diante.
GABRIEL.LOGAN 01/03/2005 12:56:56
#70539
da uma ajudinha ai gente...
USUARIO.EXCLUIDOS 01/03/2005 14:03:19
#70552
Resposta escolhida
Gabriel Vê o exemplo abaixo ajuda
'Adding line numbers to the front of text in a rich text box
'Example by HeSaidJoe
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long
Private Const EM_GETLINE = &HC4
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1
Private Sub Command1_Click()
Dim lngCount As Long
Dim lngLineIndex As Long
Dim lngLength As Long
Dim strBuffer As String
Dim strRichText As String
Dim i As Integer
'Get Line count
lngCount = SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0, 0)
With RichTextBox1
For i = 0 To lngCount - 1
'Get line index
lngLineIndex = SendMessage(.hwnd, EM_LINEINDEX, i, 0)
'get line length
lngLength = SendMessage(.hwnd, EM_LINELENGTH, lngLineIndex, 0)
'resize buffer
strBuffer = Space(lngLength)
'get line text
Call SendMessageStr(.hwnd, EM_GETLINE, i, ByVal strBuffer)
'Number each line
strRichText = strRichText & CStr(i + 1) & " " & strBuffer & vbCrLf
Next
'rewrite numbered text in RichTextBox
.Text = strRichText
End With
End Sub
Private Sub Form_Load()
With RichTextBox1
.Text = "line one" & vbCrLf
.Text = .Text & "line two" & vbCrLf
.Text = .Text & "line three"
End With
APi-Guide v 3.7 - Copyright © The KPD-Team, 1998-2002
GABRIEL.LOGAN 01/03/2005 19:20:25
#70626
Valew WCOSTA!
Tópico encerrado , respostas não são mais permitidas