Jump to content

Recommended Posts

Posted

For a college assignment I have to create a program in Visual Basic that can extract data from 3 textboxes and be able to print them and show them in print preview. I have added 3 labels and a button onto the form to test if the variables are functioniing, which they are.

But when I input text into the text boxes and press Print Preview it displays the print preview but with a blank page..

 

Any ideas?

 

Here's my code:

 

Public Class Form1
    Dim NameStore As String
    Dim EquipmentStore As String
    Dim TimeStore As Integer
    Dim X, Y As Integer
    Dim FontHeight1 As Integer
    Dim Myfont As New Font("Arial", 12, FontStyle.Regular)
    Dim assign As Boolean = False
    Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintToolStripMenuItem.Click
        assign = True
        If assign = True Then
            assign = False
            NameStore = NameBox.Text
            EquipmentStore = EquipmentBox.Text
            TimeStore = CInt(TimeBox.Text)

            X = 100
            Y = 100

            Y = Y + FontHeight1
            e.Graphics.DrawString(NameStore, Myfont, Brushes.Black, X, Y)

            X = X + 150
            e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y)

            X = X + 150
            e.Graphics.DrawString(TimeStore, Myfont, Brushes.Black, X, Y)

            FontHeight1 = Myfont.GetHeight(e.Graphics)
            Y = Y + FontHeight1
            e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y)

            X = 100
            Y = Y + FontHeight1
            e.Graphics.DrawString(EquipmentStore, Myfont, Brushes.Black, X, Y)
        End If
    End Sub

    Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
        PrintPreviewDialog1.Document = PrintDocument1

        PrintPreviewDialog1.ShowDialog()
    End Sub

    Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
        End
    End Sub
    Private Sub traceBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles traceBtn.Click
        NameStore = NameBox.Text
        EquipmentStore = EquipmentBox.Text
        TimeStore = CInt(TimeBox.Text)

        nameLabel.Text = NameStore
        eqLabel.Text = EquipmentStore
        timeLabel.Text = TimeStore

    End Sub
End Class

Posted

We don't have many programmers here, and I can't help you personally. Sorry for any inconviniences mate.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...