Web Hosting Talk







View Full Version : [VB] Rich Text Box - Two Tricks


VisualBasic
09-22-2005, 02:41 PM
In your form, or function simply do this to copy the text to the clipboard of Windows.

Clipboard.SetText ActiveForm.rtfText.SelRTF


Pasting is pretty much the opposite!

ActiveForm.rtfText.SelRTF = Clipboard.GetText

Want to print what's in your programs box?

If ActiveForm Is Nothing Then Exit Sub


With dlgCommonDialog
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
If Err <> MSComDlg.cdlCancel Then
ActiveForm.rtfText.SelPrint .hDC
End If
End With