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
Résumé par IA: 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.
Code 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
The program is too short to upload so i thought it would be better to create a tutorial :P
<br>
<br>
<font coloe=#0099ff>Before you can make the CD open or close you have to add
<b>MMSYSTEM</b> to the <b>uses</b> section of the code.
The function used to open the CD is <b>MciSendString;</b>
The function takes for arguments which are:
<b>lpszCommand:</b><i> This command is need to tell the function what to do</i>
<b>lpszReturnString:</b><i> This holds the string returned by the command</i>
<b>cchReturn:</b><i> The size argument is the size of the return string.</i>
<b>hwndCallback:</b><i> is the window that called texecuted the command ie the form.</i>
Since we dont want the function to return anything we want it to perform a
task we set "lpszReturnString" to nil and "cchReturn" to 0
The command to open the CD is <b>"Set CDAudio Door Open"</b>
The command to close the CD is the same apart from you change 'Open' to
'Closed'
<br>
<br>
<table align=center border=1 bordercolor=navy cellspacing=0 cellpadding=0>
<tr>
<td bgcolor=navy><font color=white> Open/close CD</font></td>
</tr>
<tr>
<td> MciSendString('Set CDAudio Door Open', nil, 0, form1.Handle);</td>
</tr>
<tr>
<td>
MciSendString('Set CDAudio Door Closed', nil, 0, form1.Handle);</td>
</tr>
</table>
Rate The tutorial, if not for the content then for the se of html tables :D - MyerSoft site comming soon
Commentaires originaux (3)
Récupéré via Wayback Machine