Hallo Leute!
Bin gerade dabei, ein Programm für Hotelbuchung zu machen, komme aber mit dem Druck nicht klar der 2. Form. Kann mir jemand sagen wie das design der form2 auszusehen hat mit labels damit es vernünftig ausgedruckt wird?
img821.imageshack.us/i/picturexa.jpg/ So sieht das 2. Formular aus.
Bin gerade dabei, ein Programm für Hotelbuchung zu machen, komme aber mit dem Druck nicht klar der 2. Form. Kann mir jemand sagen wie das design der form2 auszusehen hat mit labels damit es vernünftig ausgedruckt wird?
img821.imageshack.us/i/picturexa.jpg/ So sieht das 2. Formular aus.
VB.NET-Quellcode
- Public Class Form1
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Class1.Form1 = Me
- ComboBox1.Items.Add("Economy")
- ComboBox1.Items.Add("Business")
- ComboBox1.Items.Add("Royal")
- ComboBox2.Items.Add("Economy")
- ComboBox2.Items.Add("Business")
- ComboBox2.Items.Add("Royal")
- ComboBox3.Items.Add("Economy")
- ComboBox3.Items.Add("Business")
- ComboBox3.Items.Add("Royal")
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim Form2 As New Form2
- Dim SingleRoom As Double
- Dim TwinRoom As Double
- Dim TripleRoom As Double
- Dim Pets As Double
- Dim Total As Double
- If ComboBox1.Text = "Choose Class" Then
- SingleRoom = 0.0
- Else
- If ComboBox1.Text = "Economy" Then
- SingleRoom = SingleR + Economy
- End If
- If ComboBox1.Text = "Business" Then
- SingleRoom = SingleR + Business
- End If
- If ComboBox1.Text = "Royal" Then
- SingleRoom = SingleR + Royal
- End If
- End If
- If ComboBox2.Text = "Choose Class" Then
- TwinRoom = 0.0
- Else
- If ComboBox2.Text = "Economy" Then
- TwinRoom = TwinR + Economy
- End If
- If ComboBox2.Text = "Business" Then
- TwinRoom = TwinR + Business
- End If
- If ComboBox2.Text = "Royal" Then
- TwinRoom = TwinR + Royal
- End If
- End If
- If ComboBox3.Text = "Choose Class" Then
- TripleRoom = 0.0
- Else
- If ComboBox3.Text = "Economy" Then
- TripleRoom = TripleR + Economy
- End If
- If ComboBox3.Text = "Business" Then
- TripleRoom = TripleR + Business
- End If
- If ComboBox3.Text = "Royal" Then
- TripleRoom = TripleR + Royal
- End If
- End If
- If CheckBox1.Checked = "0" Then
- Pets = 0.0
- Else
- Pets = 30.0
- End If
- Total = SingleRoom * Val(TextBox1.Text) + TwinRoom * Val(TextBox2.Text) + TripleRoom * Val(TextBox3.Text) + Pets
- If ComboBox1.Text = "Choose Class" Then
- Form2.Label21.Text = "-------"
- Form2.Label5.Text = "-----"
- Form2.Label6.Text = "0"
- ElseIf TextBox1.TextLength = "0" Then
- Form2.Label21.Text = "-------"
- Form2.Label5.Text = "-----"
- Form2.Label6.Text = "0"
- Else
- Form2.Label21.Text = ComboBox1.Text
- Form2.Label5.Text = Format(SingleRoom, "Currency")
- Form2.Label6.Text = TextBox1.Text
- End If
- If ComboBox2.Text = "Choose Class" Then
- Form2.Label20.Text = "-------"
- Form2.Label8.Text = "-----"
- Form2.Label9.Text = "0"
- ElseIf TextBox2.TextLength = "0" Then
- Form2.Label20.Text = "-------"
- Form2.Label8.Text = "-----"
- Form2.Label9.Text = "0"
- Else
- Form2.Label20.Text = ComboBox2.Text
- Form2.Label8.Text = Format(TwinRoom, "Currency")
- Form2.Label9.Text = TextBox2.Text
- End If
- If ComboBox3.Text = "Choose Class" Then
- Form2.Label19.Text = "-------"
- Form2.Label11.Text = "-----"
- Form2.Label12.Text = "0"
- ElseIf TextBox3.TextLength = "0" Then
- Form2.Label19.Text = "-------"
- Form2.Label11.Text = "-----"
- Form2.Label12.Text = "0"
- Else
- Form2.Label19.Text = ComboBox3.Text
- Form2.Label11.Text = Format(TripleRoom, "Currency")
- Form2.Label12.Text = TextBox3.Text
- End If
- If CheckBox1.Checked = "0" Then
- Form2.Label14.Text = ""
- Else
- Form2.Label14.Text = Format(Pets, "Currency")
- End If
- Form2.Label17.Text = Format(Total, "Currency")
- If ComboBox1.Text = "Choose Class" And ComboBox2.Text = "Choose Class" And ComboBox3.Text = "Choose Class" Then
- MsgBox("Choose at least one room and class!", 0)
- End If
- Form2.Show()
- End Sub
- Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
- End Sub
- Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
- End Sub
- End Class
- 5.2 Form2.vb
- Imports System.Drawing.Printing
- Public Class Form2
- Inherits System.Windows.Forms.Form
- Dim LabelArray(5, 4) As Label
- Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Class1.Form2 = Me
- End Sub
- Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Class1.Form2.Hide()
- End Sub
- Private WithEvents myDocument As PrintDocument
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- LabelArray(1, 1) = Label1
- LabelArray(1, 2) = Label22
- LabelArray(1, 3) = Label2
- LabelArray(1, 4) = Label3
- LabelArray(2, 1) = Label4
- LabelArray(2, 2) = Label21
- LabelArray(2, 3) = Label4
- LabelArray(2, 4) = Label6
- LabelArray(3, 1) = Label7
- LabelArray(3, 2) = Label20
- LabelArray(3, 3) = Label8
- LabelArray(3, 4) = Label9
- LabelArray(4, 1) = Label13
- LabelArray(4, 3) = Label14
- LabelArray(5, 3) = Label5
- LabelArray(5, 4) = Label17
- myDocument = New PrintDocument
- myDocument.Print()
- End Sub
- Private Sub myDocument_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles myDocument.PrintPage
- Dim myText As String
- Dim N As Integer = 1
- Dim T As New Date
- Dim myFont As New Font("Courier New", 12, FontStyle.Regular, GraphicsUnit.Point)
- e.Graphics.DrawString(Label15.Text, myFont, Brushes.Black, (50 + 50), 50)
- e.Graphics.DrawString(Date.Today(), myFont, Brushes.Black, (50 + 100), (50 + 24))
- N = N + 2
- myText = Label1.Text + " " + Label22.Text + " " + Label2.Text + " " + Label3.Text
- N = N + 2
- e.Graphics.DrawString(myText, myFont, Brushes.Black, 50, (50 + N * 24))
- myText = Label4.Text + " " + Label21.Text + " " + Label5.Text + " " + Label6.Text
- N = N + 1
- e.Graphics.DrawString(myText, myFont, Brushes.Black, 50, (50 + N * 24))
- myText = Label7.Text + " " + Label20.Text + " " + Label8.Text + " " + Label9.Text
- N = N + 1
- e.Graphics.DrawString(myText, myFont, Brushes.Black, 50, (50 + N * 24))
- myText = Label10.Text + " " + Label19.Text + " " + Label11.Text + " " + Label12.Text
- N = N + 1
- e.Graphics.DrawString(myText, myFont, Brushes.Black, 50, (50 + N * 24))
- myText = Label13.Text + " " + " " + Label14.Text
- N = N + 1
- e.Graphics.DrawString(myText, myFont, Brushes.Black, 50, (50 + N * 24))
- myText = "------------------------------------------------------------"
- N = N + 1
- e.Graphics.DrawString(myText, myFont, Brushes.Black, 50, (50 + N * 24))
- myText = Label16.Text + " " + " " + Label17.Text
- N = N + 1
- e.Graphics.DrawString(myText, myFont, Brushes.Black, 50, (50 + N * 24))
- End Sub
- Private Sub PrintDocument1_QueryPageSettings(ByVal sender As Object, ByVal e As System.Drawing.Printing.QueryPageSettingsEventArgs) Handles myDocument.QueryPageSettings
- e.PageSettings.Landscape = False
- End Sub
- End Class
- 5.3 Module1.vb
- Module Module1
- Public Const Economy = 60.0
- Public Const Business = 100.0
- Public Const Royal = 160.0
- Public Const SingleR = 30.0
- Public Const TwinR = 45.0
- Public Const TripleR = 60.0
- Sub main()
- Dim Form2 = New Form2
- Form2.ShowDialog()
- End Sub
- End Module
- 5.4 Class1.vb
- Public Class Class1
- Public Shared Form1 As Form
- Public Shared Form2 As Form
- End Class