4 Replies - 6393 Views - Last Post: 16 December 2008 - 06:11 PM Rate Topic: -----

#1 cliffste  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 17-November 08

Print to File

Posted 15 December 2008 - 06:35 PM

My problem is not being able to print to file my program that I’m able to print fine.
I need for someone to tell me what arguments to put in to correct the errors or show me
A different way to output my program to a file.
>>Just the start of my print program<<
 Private Sub PrintSmallText(ByVal sender As Object, _
	  ByVal ev As PrintPageEventArgs)
		'Use DrawString to create text in a Graphics object
		ev.Graphics.DrawString("Facts", New Font("Times New Roman", _
		  10, FontStyle.Bold), Brushes.Black, 80, 20)
		ev.Graphics.DrawString("Current as of " + frmTab.DateTimePickerToday.Text, _
		  New Font("Times New Roman", 8, FontStyle.Regular), Brushes.Black, 90, 40)
		

  
	Public Sub btnprFileSmall_Click(ByVal sender As System.Object, ByVal e As _   System.EventArgs) Handles btnprSmall.Click

		Try
			PrintDialog1.AllowSomePages = True
			PrintDialog1.AllowPrintToFile = True
			PrintDialog1.ShowHelp = True
			Dim PrintDia As New PrintDialog
			PrintDialog1.Document = PrintSmallText() ‘Errors shown below
			PrintDia.ShowDialog()
			Dim result As DialogResult = PrintDialog1.ShowDialog()
			If (result = Windows.Forms.DialogResult.OK) Then
				PrintSmallText.Print()
			End If
		Catch ex As Exception  'catch printing exception
			MessageBox.Show("Sorry--there is a problem printing", _
			  ex.ToString())
		End Try
	End Sub

Error	1	Argument not specified for parameter 'ev' of 'Private Sub PrintSmallText(sender As				   Object, ev As System.Drawing.Printing.PrintPageEventArgs)'.
Error 2	Argument not specified for parameter 'sender' of 'Private Sub PrintSmallText(sender As Object, ev As System.Drawing.Printing.PrintPageEventArgs)'.

>>This Prints fine<<
  Public Sub btnprSmall_Click(ByVal sender As System.Object, ByVal e As _
	  System.EventArgs) Handles btnprSmall.Click
		Try
			Dim PrintDoc As New PrintDocument
			AddHandler PrintDoc.PrintPage, AddressOf Me.PrintSmallText
			PrintDoc.Print()
		Catch ex As Exception
			MessageBox.Show("Didn't print--printing problem", _
			  ex.ToString())
		End Try
	End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Print to File

#2 cliffste  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 17-November 08

Re: Print to File

Posted 16 December 2008 - 12:54 PM

I'm tring this again with a different title.
My problem is not being able to print to file my program that I’m able to print fine.
I need for someone to tell me what arguments to put in to correct the errors or show me
A different way to output my program to a file.
>>Just the start of my print program<<
 Private Sub PrintSmallText(ByVal sender As Object, _
	  ByVal ev As PrintPageEventArgs)
		'Use DrawString to create text in a Graphics object
		ev.Graphics.DrawString("Facts", New Font("Times New Roman", _
		  10, FontStyle.Bold), Brushes.Black, 80, 20)
		ev.Graphics.DrawString("Current as of " + frmTab.DateTimePickerToday.Text, _
		  New Font("Times New Roman", 8, FontStyle.Regular), Brushes.Black, 90, 40)
		

  
	Public Sub btnprFileSmall_Click(ByVal sender As System.Object, ByVal e As _   System.EventArgs) Handles btnprSmall.Click

		Try
			PrintDialog1.AllowSomePages = True
			PrintDialog1.AllowPrintToFile = True
			PrintDialog1.ShowHelp = True
			Dim PrintDia As New PrintDialog
			PrintDialog1.Document = PrintSmallText() ‘Errors shown below
			PrintDia.ShowDialog()
			Dim result As DialogResult = PrintDialog1.ShowDialog()
			If (result = Windows.Forms.DialogResult.OK) Then
				PrintSmallText.Print()
			End If
		Catch ex As Exception  'catch printing exception
			MessageBox.Show("Sorry--there is a problem printing", _
			  ex.ToString())
		End Try
	End Sub

Error	1	Argument not specified for parameter 'ev' of 'Private Sub PrintSmallText(sender As				   Object, ev As System.Drawing.Printing.PrintPageEventArgs)'.
Error 2	Argument not specified for parameter 'sender' of 'Private Sub PrintSmallText(sender As Object, ev As System.Drawing.Printing.PrintPageEventArgs)'.

>>This Prints fine<<
  Public Sub btnprSmall_Click(ByVal sender As System.Object, ByVal e As _
	  System.EventArgs) Handles btnprSmall.Click
		Try
			Dim PrintDoc As New PrintDocument
			AddHandler PrintDoc.PrintPage, AddressOf Me.PrintSmallText
			PrintDoc.Print()
		Catch ex As Exception
			MessageBox.Show("Didn't print--printing problem", _
			  ex.ToString())
		End Try
	End Sub


Was This Post Helpful? 0
  • +
  • -

#3 ddollar  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 40
  • Joined: 16-January 08

Re: Print to File

Posted 16 December 2008 - 01:32 PM

I think you are referencing parameters in your Private Sub PrintSmallText but not supplying them.

In place of >> PrintDialog1.Document = PrintSmallText() ‘Errors shown below

try >> PrintDialog1.Document = PrintSmallText(Sender,ev) ‘Errors shown below

Also try using Opton Strict On (very top of code file) and the IDE will ID errors as you make them.

ddollar
Was This Post Helpful? 0
  • +
  • -

#4 cliffste  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 17-November 08

Re: Print to File

Posted 16 December 2008 - 05:57 PM

View Postddollar, on 16 Dec, 2008 - 12:32 PM, said:

I think you are referencing parameters in your Private Sub PrintSmallText but not supplying them.

In place of >> PrintDialog1.Document = PrintSmallText() ‘Errors shown below

try >> PrintDialog1.Document = PrintSmallText(Sender,ev) ‘Errors shown below

Also try using Opton Strict On (very top of code file) and the IDE will ID errors as you make them.

ddollar

I tried the changes that you gave me and now I get a different error message.
Error 1 Expression does not produce a value.
I'm grateful for your help but it looks like I need a little more.
cliffste
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Print to File

Posted 16 December 2008 - 06:11 PM

Please don't create duplicate topics, it really isn't going to get you help any faster. At times you're just going to have to show some patience when it comes to things like this, we all have lives outside of Dream.In.Code and sometimes it can take time to get a reply, creating a duplicate topic isn't going to speed that up at all. Topics merged :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1