Insert text
This code inserts text at the end of a textbox (or anything with a .text, .selstart, .sellength, and .seltext property) without adding the entire contents of the textbox all over again
it saves a lot of time with long text and opening text files
Original Author: justin holland
Inputs
textcontrol as object,text as string
Assumptions
nothing
Returns
1 if successful
0 if any error occurs
Side Effects
none i know of
API Declarations
nope
Code
Function AddText(textcontrol As Object, text2add As String)
On Error GoTo errhandlr
tmptxt$ = textcontrol.Text 'just in case of an accident
textcontrol.SelStart = Len(textcontrol.Text) ' move the "cursor" to the end of the text file
textcontrol.SelLength = 0 ' highlight nothing (this becomes the selected text)
textcontrol.SelText = text2add ' set the selected text ot text2add
AddText = 1
GoTo quitt ' goto the end of the sub
'error handlers
errhandlr:
If Err.Number <> 438 Then 'check the error number and restore the
textcontrol.Text = tmptxt$ 'original text if the control supports it
End If
AddText = 0
GoTo quitt
quitt:
tmptxt$ = ""
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.