|
-
Jun 21st, 2000, 02:07 AM
#9
_______
as per your question
no...it is a private sub that will save the file for you.
if you start a new project and add a richtextbox1 and
a command button (Command1) to it.
then copy and paste the code Serge gave you into your applicaion. Here it is with the little piece I added to
save your file to afile.txt on your c drive..
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
Open "c:\afile.txt" For Output As #1
Dim myline
myline = richtextbox1.Text
Write #1, myline
Close
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|