Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
View and Print Text Files
Author:
Saiful Bahari S
E-mail:
Click to e-mail author
Submitted:
2/9/2004
Version:
VB5
Compatibility:
VB5, VB6
Category:
Controls
Views:
28579
Open .txt files and print without fuss. You need a form, three buttons, a common dialog control, and a rich text box.
Declarations:
'none
Code:
Private Sub Command1_Click() ' The RichTextBox control is named "rtfData." ' The CommonDialog is named "dlgOpenFile." ' Declare a String variable for file name. ' Show the Open File dialog box, and set the ' variable to the filename. Dim strOpen As String CommonDialog1.ShowOpen strOpen = CommonDialog1.filename ' Use LoadFile method to open the file. RichTextBox1.LoadFile strOpen End Sub 'To save a file is just as easy, using the SaveFile method: Private Sub SaveFile() Dim strNewFile As String dlgOpenFile.ShowSave strNewFile = dlgOpenFile.filename rtfData.SaveFile strNewFile End Sub End Sub Private Sub Command2_Click() End End Sub Private Sub Command3_Click() CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums If RichTextBox1.SelLength = 0 Then CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages Else CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection End If CommonDialog1.ShowPrinter Printer.Print "" RichTextBox1.SelPrint CommonDialog1.hDC End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement