Hi. okay, doing a chapter of a book for an example for beginning in visual basic by Julia Milspaw. and doing the example, where you have three menus, file, edit and about. the file menu, has various printing options, and you select items from a combo box and a list box. well, have got several errors, and if any one can help me out on this one, let me know. and the errors i have got: 1. not likeing the printAllPrintDocument.Print, PrintSelected commands in vb.dot express 2008. and also, had to type in hand coding a couple of print click events for printing the pages and the selected pages, but giving me not liking the Hands clause of the private class event procedure. and hand typed it from the example, exactly. so, why is this happening. really annoying me, as a beginner vb programmer, and taught me some concepts about loopps, list boxes, combo boxes, and gave me experience how to code loops, for loop, combo lists, how to add items, remove items. etc. so, will i know this is a pain, but the only way you can see, is for me to post my code, and see if you can help me out, and also will post the error messages below, about 6 in total. so if you can help let me know. cheers Marvin. 'Project: Ch07HandsOn 'Programmer: Bradley/Millspaugh 'Date: June 2005 'Description: Maintain a list of coffee flavors; print the selected flavor ' of coffee and syrup or print a list of all of the coffee flavors. 'Folder: Ch07HandsOn Public Class frmBilling Private Sub menExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menExitToolStripMenuItem.Click 'End the program. Me.Close() End Sub Private Sub menAddCoffeeFlavorToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menAddCoffeeFlavorToolStripMenuItem.Click ' Add a new coffee flavor to the coffee list. With Me.cboCoffeeComboBox ' Test for blank input. If .Text <> "" Then ' Make sure item is not already on the list. Dim booItemFoundBoolean As Boolean Dim intItemIndexInteger As Integer Do Until booItemFoundBoolean Or intItemIndexInteger = .Items.Count If .Text = .Items(intItemIndexInteger).ToString() Then booItemFoundBoolean = True Exit Do Else intItemIndexInteger += 1 End If Loop If booItemFoundBoolean Then MessageBox.Show("Duplicate item.", "Add Failed", _ MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Else ' If it's not in the list, add it. .Items.Add(.Text) .Text = "" End If Else MessageBox.Show("Enter a coffee flavor to add", _ "Missing Data", MessageBoxButtons.OK, _ MessageBoxIcon.Exclamation) End If .Focus() End With End Sub Private Sub menPrintAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menPrintAllToolStripMenuItem.Click ' Begin the print process to print all items. printAllPrintDocument.Print() End Sub Private Sub menPreviewAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menPreviewAllToolStripMenuItem.Click ' Begin the process for print preview of all items. dlgPrintPreviewDialog.Document = printAllPrintDocument dlgPrintPreviewDialog.ShowDialog() End Sub Private Sub menPrintSelectedFlavorsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menPrintSelectedFlavorsToolStripMenuItem.Click ' Begin the print process to print the selected item. With Me If .lstSyrupListBox.SelectedIndex = -1 Then ' Select (None) if nothing selected. .lstSyrupListBox.SelectedIndex = 0 End If If .cboCoffeeComboBox.SelectedIndex <> -1 Then ' Items selected. printSelectedPrintDocument.Print() Else ' No item selected. MessageBox.Show("Select a flavor from the coffee list", _ "Print Selection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If End With End Sub Private Sub menPreviewSelectedToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menPreviewSelectedToolStripMenuItem.Click ' Begin the process for print preview of the selected item. With Me If .lstSyrupListBox.SelectedIndex = -1 Then ' Select (None) if nothing selected. .lstSyrupListBox.SelectedIndex = 0 End If if .cboCoffeeComboBox.SelectedIndex <> -1 then ' Item selected. .dlgPrintPreviewDialog.Document = printSelectedPrintDocument .dlgPrintPreviewDialog.ShowDialog() else ' No item selected. MessageBox.Show("Select a flavor from the coffee list", _ "Print Selection", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) end If End With End Sub Private Sub printAllPrintDocument_PrintPage(ByVal sender As Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) _ Handles printAllPrintDocument.PrintPage ' Handle printing and print previews when printing all. Dim ptrPrintFont As New Font("Arial", 12) Dim sinLineHeight As Single = ptrPrintFont.GetHeight + 2 Dim sinHorizontalPrintLocationSingle As Single = e.MarginBounds.Left Dim sinVerticalPrintLocationSingle As Single = e.MarginBounds.Top Dim strPrintLineString As String Dim intListIndexInteger As Integer ' Print the heading. Using HeadingFont As New Font("Arial", 14, FontStyle.Bold) e.Graphics.DrawString("Flavors", HeadingFont, _ Brushes.Black, sinHorizontalPrintLocationSingle, _ sinVerticalPrintLocationSingle) End Using ' Loop through the entire list. For intListIndexInteger = 0 To Me.cboCoffeeComboBox.Items.Count - 1 ' Increment the Y position for the next line. sinVerticalPrintLocationSingle += sinLineHeightSingle ' Set up a line. strPrintLineString = Me.cboCoffeeComboBox.Items(intListIndexInteger).ToString() ' Send the line to the graphics page object. e.Graphics.DrawString(strPrintLineString, ptrPrintFont, _ Brushes.Black, sinHorizontalPrintLocationSingle, _ sinVerticalPrintLocationSingle) Next intListIndexInteger End Sub Private Sub printSelectedPrintDocument_PrintPage(ByVal sender As System.Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) _ Handles printSelectedPrintDocument.PrintPage ' Handle printing and print previews when printing selected items. Dim ptrPrintFont As New Font("Arial", 12) Dim ptrHeadingFont As New Font("Arial", 14, FontStyle.Bold) Dim sinLineHeightSingle As Single = ptrPrintFont.GetHeight + 2 Dim sinHorizontalPrintLocationSingle As Single = e.MarginBounds.Left Dim sinVerticalPrintLocationSingle As Single = e.MarginBounds.Top Dim strPrintLineString As String ' Set up and display heading lines. strPrintLineString = "Print Selected Item" e.Graphics.DrawString(strPrintLineString, ptrHeadingFont, _ Brushes.Black, sinHorizontalPrintLocationSingle, _ sinVerticalPrintLocationSingle) strPrintStringLine = "By Marvin Hunkin" sinVerticalPrintLocationSingle += sinLineHeightSingle e.Graphics.DrawString(strPrintLineString, ptrHeadingFont, _ Brushes.Black, sinHorizontalPrintLocationSingle, _ sinVerticalPrintLocationSingle) ' Leave a blank line between the heading and detail line. sinVerticalPrintLocationSingle += sinLineHeightSingle * 2 ' Set up the selected line. strPrintLineString = "Coffee : " & Me.cboCoffeeComboBox.Text & _ " Syrup: " & Me.lstSyrupListBox.Text ' Send the line to the graphics page object. e.Graphics.DrawString(strPrintLineString, ptrPrintFont, _ Brushes.Black, sinHorizontalPrintLocationSingle, _ sinVerticalPrintLocationSingle) End Sub Private Sub menClearCoffeeListToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menClearCoffeeListToolStripMenuItem.Click ' Clear the coffee list. dim dlgResponseDialogResult as DialogResult dlgResponseDialogResult = messageBox.Show("Clear the coffee flavor list?", _ "Clear Coffee List", messageBoxButtons.YesNo, messageBoxIcon.Question) if dlgResponseDialogResult = DialogResult.Yes Then Me.cboCoffeeComboBox.Items.Clear() end if End Sub Private Sub menRemoveCoffeeFlavorToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menRemoveCoffeeFlavorToolStripMenuItem.Click ' Remove the selected coffee from list. With Me .cboCoffeeComboBox if .SelectedIndex <> -1 Then .Items.RemoveAt(.SelectedIndex) else messageBox.Show("First remove the coffee to remove", _ "No selection made", messageBoxButtons.Ok, _ messageBoxIcon.Exclamation) End If End With End Sub Private Sub menCountCoffeeListToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menCountCoffeeListToolStripMenuItem.Click ' Display a count of the coffee list. messageBox.Show("The number of coffee types is" & _ Me.cboCoffeeComboBox.Items.Count, "R 'n R Coffee Type Count", _ messageBoxButtons.Ok, messageBoxIcon.Information) End Sub Private Sub menAboutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menAboutToolStripMenuItem.Click ' Display the About form. frmAboutBox.ShowDialog() End Sub End Class Error 1 Name 'printAllPrintDocument' is not declared. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 136 9 Ch07HandsOn Error 2 Name 'printAllPrintDocument' is not declared. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 162 42 Ch07HandsOn Error 3 Name 'printSelectedPrintDocument' is not declared. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 193 17 Ch07HandsOn Error 4 Name 'printSelectedPrintDocument' is not declared. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 234 51 Ch07HandsOn Error 5 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 261 9 Ch07HandsOn Error 6 Name 'sinLineHeightSingle' is not declared. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 295 47 Ch07HandsOn Error 7 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 336 9 Ch07HandsOn Error 8 Name 'strPrintStringLine' is not declared. C:\DOCS\Tafe\CertificateFourProgramming\CertFour\Programming\VisualBasic\Book\VisualBasicProgramming\ChapterSeven\Example\Ch07HandsOn\Ch07HandsOn\frmBilling.vb 357 9 Ch07HandsOn __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind