Advertisement
2002C Miscellaneous #8742

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

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
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

Upload
Commenti originali (3)
Recuperato da Wayback Machine