Why does this code not find the txtDocument.Text statement  
Author Message
robertlamour





PostPosted: Visual Basic Express Edition, Why does this code not find the txtDocument.Text statement Top

I am trying to use PrintPreviewDialog, But the Compiler is not finding the txtDocument.Text. I open a file and then want to printpreview dialog but I get a blue underline error with the ppdPreview.Document = txtDocument.Text

Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrintPreview.Click

ppdPreview.Document = txtDocument.Text

ppdPreview.ShowDialog()

End Sub

Sub OpenDOcument()

' Use the OpenFileDialog control to get a file name

Dim inputFile As StreamReader

Dim strDocumentName As String

With ofdOpenFile

.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"

.Title = "Select a File to Open"

End With

If ofdOpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then

strDocumentName = ofdOpenFile.FileName

inputFile = File.OpenText(strDocumentName)

txtDocument.Text = inputFile.ReadToEnd

End If

End Sub



Visual Studio Express Editions32  
 
 
Ken Tucker





PostPosted: Visual Basic Express Edition, Why does this code not find the txtDocument.Text statement Top

The printpreviewdialog.document is expecting a printdocument not a text document. You have to write code to be able to print a text document