Creating a Simple Coffee Ordering System

Hello there, It's been a long time since I made my last post on my blog. I have been quite busy with my work and other activities but now I'm back. Thank you to all the visitors who are still visiting my site even though I have not active for more than a year (I think). I am here again share some tutorials and posting some new stuff here.

For today's tutorial we are going to create a simple Ordering System. Lets get started!

First you need to add the following control objects after you created your New Project.

REQUIREMENTS:
1 Form
1 ToolStrip
1 PrintPreviewDialog
1 OpenFileDialog
1 PrintDocument
1 SaveFileDialog
1 TabControl
1 RichTextBox
2 Timer
4 GroupBox
6 Buttons
16 Checkbox
11 Labels

Select your Form then go to Properties and set the following values:

Project Name: CoffeeOrderingSystem
StartPosition Property: CenterScreen
Text Property: Coffee Ordering System


For the Labels you need to set Text Properties of each labels

Label1 – Cost of Drinks           Label3 – Service Charge         Label5 - Tax
Label2 – Cost of Cakes            Label4 – Sub Total                   Label6 – Amount
Label7 *Welcome* and Label8 *Time* should be empty in Text Property,
Label9, 10 and 11 will be explain later in the exercise.


For the Buttons you need also to set the Name and Text Properties 

Name Properties                    Text Properties
btnOrder                                 TAP Order
btnCancel                                Cancel Order
btnPay                                     PAY
btnClear                                  CLEAR ALL
btnExit                                      EXIT

GroupBox
Name Properties                     Text Properties
GroupBox1                              DRINKS
GroupBox2                              CAKES
GroupBox3                              *empty*

CheckBox
Name Properties                     Text Properties
chkIceCapp                              Iced - Cappuccino (143.52)
chkAmerica                             American Coffee (129.60)
chkAfrica                                 African Coffee (115.20)
chkVales                                  Vales Coffee (109.73)
chkCapp                                  Cappuccino (123.49)
chkIcedLatte                            Iced - Latte (131.35)
chkEspresso                             Espresso (117.39)
chkLatte                                  Latte (102.59)
chkQueens                              Queen's Park Chocolate Cake (151.48)
chkCarlton                               Carlton Hill Chocolate Cake (138.46)
chkKillburn                              Killburn Chocolate Cake (118.75)
chkLagos                                 Lagos Chocolate Cake (93.95)
chkBoston                                Boston Cream Cake (98.25)
chkBlack                                  Black Forest Cake (125.98)
chkRed                                    Red Velvet Cake (132.53)
chkCoffee                                Coffee Cake (89.85)

TextBox
Name Properties                     Name Properties                   Name Properties
txtIceCapp                               txtQueen                                 txtDrinks
txtAmerica                              txtCarlton                                txtCakes
txtAfrica                                  txtKillburn                               txtCharge
txtVales                                   txtLagos                                   txtSubTotal
txtCapp                                    txtBoston                                 txtTax
txtIcedLatte                             txtBlack                                   txtAmount
txtEspresso                              txtRed                                      txtLatte 
txtCoffee

Timer
Timer1
Enabled Properties              Interval Properties
False                                        100 
Timer2
Enabled Properties              Interval Properties
True                                         80

This will be your output, the colors may vary



Next is coding!

Double Click the Timer1 and type this code

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Static i As Integer
        Dim welcome As String
        welcome = "W e l c o m e  t o  C o f f e e  O r d e r i n g   S y s t e m"
        i = i + 1
        Label7.Text = Label7.Text & Mid(welcome, i, 1)
        If Label7.Text = welcome Then
            Timer1.Enabled = False
        End If
End Sub


Double Click the Timer2 and type this code

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Label8.Text = "Time Check:  " & TimeOfDay
End Sub


Double Click the Button - btnExit and type this code

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Application.Exit()
        Me.Close()
End Sub

Double Click the Form and type this code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
        Timer1.Interval = 50
        Call Clear()
End Sub

Next is we will create a Public Sub for Clear

Public Sub Clear()
        txtIceCapp.Text = "0"
        txtAmerica.Text = "0"
        txtAfrica.Text = "0"
        txtVales.Text = "0"
        txtCapp.Text = "0"
        txtIcedLatte.Text = "0"
        txtEspresso.Text = "0"
        txtLatte.Text = "0"
        txtQueen.Text = "0"
        txtCarlton.Text = "0"
        txtKillburn.Text = "0"
        txtLagos.Text = "0"
        txtBoston.Text = "0"
        txtBlack.Text = "0"
        txtRed.Text = "0"
        txtCoffee.Text = "0"
        txtIceCapp.Enabled = False
        txtAmerica.Enabled = False
        txtAfrica.Enabled = False
        txtVales.Enabled = False
        txtCapp.Enabled = False
        txtIcedLatte.Enabled = False
        txtEspresso.Enabled = False
        txtLatte.Enabled = False
        txtQueen.Enabled = False
        txtCarlton.Enabled = False
        txtKillburn.Enabled = False
        txtLagos.Enabled = False
        txtBoston.Enabled = False
        txtBlack.Enabled = False
        txtRed.Enabled = False
        txtCoffee.Enabled = False
        chkIceCapp.Checked = False
        chkAmerica.Checked = False
        chkAfrica.Checked = False
        chkVales.Checked = False
        chkCapp.Checked = False
        chkIcedLatte.Checked = False
        chkEspresso.Checked = False
        chkLatte.Checked = False
        chkQueens.Checked = False
        chkCarlton.Checked = False
        chkKillburn.Checked = False
        chkLagos.Checked = False
        chkBoston.Checked = False
        chkBlack.Checked = False
        chkRed.Checked = False
        chkCoffee.Checked = False
        txtDrinks.Text = "0.00"
        txtCakes.Text = "0.00"
        txtCharge.Text = "0.00"
        txtSubTotal.Text = "0.00"
        txtTax.Text = "0.00"
        txtAmount.Text = "0.00"
End Sub


For the rest of the CheckBox, this are the code

Checkbox chkIceCapp - Code

Private Sub chkIceCapp_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkIceCapp.CheckedChanged
        If chkIceCapp.Checked = True Then
            txtIceCapp.Enabled = True
            txtIceCapp.Focus()
            txtIceCapp.SelectionStart = 0
            txtIceCapp.SelectionLength = Len(txtIceCapp.Text)
        Else
            txtIceCapp.Enabled = False
            txtIceCapp.Text = 0
        End If
    End Sub

Checkbox chkAmerica - Code
   
Private Sub chkAmerica_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkAmerica.CheckedChanged
        If chkAmerica.Checked = True Then
            txtAmerica.Enabled = True
            txtAmerica.Focus()
            txtAmerica.SelectionStart = 0
            txtAmerica.SelectionLength = Len(txtAmerica.Text)
        Else
            txtAmerica.Enabled = False
            txtAmerica.Text = 0
        End If
    End Sub

Checkbox chkAfrica - Code

Private Sub chkAfrica_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkAfrica.CheckedChanged
        If chkAfrica.Checked = True Then
            txtAfrica.Enabled = True
            txtAfrica.Focus()
            txtAfrica.SelectionStart = 0
            txtAfrica.SelectionLength = Len(txtAfrica.Text)
        Else
            txtAfrica.Enabled = False
            txtAfrica.Text = 0
        End If
    End Sub

Checkbox chkVales - Code

    Private Sub chkVales_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkVales.CheckedChanged
        If chkVales.Checked = True Then
            txtVales.Enabled = True
            txtVales.Focus()
            txtVales.SelectionStart = 0
            txtVales.SelectionLength = Len(txtVales.Text)
        Else
            txtVales.Enabled = False
            txtVales.Text = 0
        End If
    End Sub

Checkbox chkCapp - Code

    Private Sub chkCapp_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCapp.CheckedChanged
        If chkCapp.Checked = True Then
            txtCapp.Enabled = True
            txtCapp.Focus()
            txtCapp.SelectionStart = 0
            txtCapp.SelectionLength = Len(txtCapp.Text)
        Else
            txtCapp.Enabled = False
            txtCapp.Text = 0
        End If
    End Sub

Checkbox chkIcedLatte - Code

    Private Sub chkIcedLatte_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkIcedLatte.CheckedChanged
        If chkIcedLatte.Checked = True Then
            txtIcedLatte.Enabled = True
            txtIcedLatte.Focus()
            txtIcedLatte.SelectionStart = 0
            txtIcedLatte.SelectionLength = Len(txtIcedLatte.Text)
        Else
            txtIcedLatte.Enabled = False
            txtIcedLatte.Text = 0
        End If
    End Sub

Checkbox chkEspresso - Code

    Private Sub chkEspresso_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkEspresso.CheckedChanged
        If chkEspresso.Checked = True Then
            txtEspresso.Enabled = True
            txtEspresso.Focus()
            txtEspresso.SelectionStart = 0
            txtEspresso.SelectionLength = Len(txtEspresso.Text)
        Else
            txtEspresso.Enabled = False
            txtEspresso.Text = 0
        End If
    End Sub

Checkbox chkLatte - Code

    Private Sub chkLatte_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkLatte.CheckedChanged
        If chkLatte.Checked = True Then
            txtLatte.Enabled = True
            txtLatte.Focus()
            txtLatte.SelectionStart = 0
            txtLatte.SelectionLength = Len(txtLatte.Text)
        Else
            txtLatte.Enabled = False
            txtLatte.Text = 0
        End If
    End Sub

Checkbox chkIceQueens - Code

    Private Sub chkQueens_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkQueens.CheckedChanged
        If chkQueens.Checked = True Then
            txtQueen.Enabled = True
            txtQueen.Focus()
            txtQueen.SelectionStart = 0
            txtQueen.SelectionLength = Len(txtQueen.Text)
        Else
            txtQueen.Enabled = False
            txtQueen.Text = 0
        End If
    End Sub

Checkbox chkCarlton - Code

    Private Sub chkCarlton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCarlton.CheckedChanged
        If chkCarlton.Checked = True Then
            txtCarlton.Enabled = True
            txtCarlton.Focus()
            txtCarlton.SelectionStart = 0
            txtCarlton.SelectionLength = Len(txtCarlton.Text)
        Else
            txtCarlton.Enabled = False
            txtCarlton.Text = 0
        End If
    End Sub

Checkbox chkKillburn - Code

    Private Sub chkKillburn_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkKillburn.CheckedChanged
        If chkKillburn.Checked = True Then
            txtKillburn.Enabled = True
            txtKillburn.Focus()
            txtKillburn.SelectionStart = 0
            txtKillburn.SelectionLength = Len(txtKillburn.Text)
        Else
            txtKillburn.Enabled = False
            txtKillburn.Text = 0
        End If
    End Sub

Checkbox chkLagos - Code

    Private Sub chkLagos_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkLagos.CheckedChanged
        If chkLagos.Checked = True Then
            txtLagos.Enabled = True
            txtLagos.Focus()
            txtLagos.SelectionStart = 0
            txtLagos.SelectionLength = Len(txtLagos.Text)
        Else
            txtLagos.Enabled = False
            txtLagos.Text = 0
        End If
    End Sub

Checkbox chkBoston - Code

    Private Sub chkBoston_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkBoston.CheckedChanged
        If chkBoston.Checked = True Then
            txtBoston.Enabled = True
            txtBoston.Focus()
            txtBoston.SelectionStart = 0
            txtBoston.SelectionLength = Len(txtBoston.Text)
        Else
            txtBoston.Enabled = False
            txtBoston.Text = 0
        End If
    End Sub

Checkbox chkBlack - Code

    Private Sub chkBlack_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkBlack.CheckedChanged
        If chkBlack.Checked = True Then
            txtBlack.Enabled = True
            txtBlack.Focus()
            txtBlack.SelectionStart = 0
            txtBlack.SelectionLength = Len(txtBlack.Text)
        Else
            txtBlack.Enabled = False
            txtBlack.Text = 0
        End If
    End Sub

Checkbox chkRed - Code

    Private Sub chkRed_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkRed.CheckedChanged
        If chkRed.Checked = True Then
            txtRed.Enabled = True
            txtRed.Focus()
            txtRed.SelectionStart = 0
            txtRed.SelectionLength = Len(txtRed.Text)
        Else
            txtRed.Enabled = False
            txtRed.Text = 0
        End If
    End Sub

Checkbox chkCoffee - Code

    Private Sub chkCoffee_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCoffee.CheckedChanged
        If chkCoffee.Checked = True Then
            txtCoffee.Enabled = True
            txtCoffee.Focus()
            txtCoffee.SelectionStart = 0
            txtCoffee.SelectionLength = Len(txtCoffee.Text)
        Else
            txtCoffee.Enabled = False
            txtCoffee.Text = 0
        End If
    End Sub

Button btnOrder - Code

Private Sub btnOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOrder.Click
        Dim icecapp, america, africa, vales, capp, icedlatte, espresso, latte As Double
        Dim queen, carlton, killburn, lagos, boston, black, red, coffee, tax As Double
        tax = 0.12
        icecapp = 143.52
        america = 129.6
        africa = 115.2
        vales = 109.73
        capp = 123.49
        icedlatte = 131.35
        espresso = 117.39
        latte = 102.59
        queen = 151.48
        carlton = 138.46
        killburn = 118.75
        lagos = 93.95
        boston = 98.25
        black = 125.98
        red = 132.53
        coffee = 89.85
        Dim costdrinks, costcakes, servicecharge As Double
        costdrinks = (icecapp * Val(txtIceCapp.Text)) + (america * Val(txtAmerica.Text)) + (africa * Val(txtAfrica.Text)) + _
            (vales * Val(txtVales.Text)) + (capp * Val(txtCapp.Text)) + (icedlatte * Val(txtIcedLatte.Text)) + _
            (espresso * Val(txtEspresso.Text)) + (latte * Val(txtLatte.Text))
        costcakes = (queen * Val(txtQueen.Text)) + (carlton * Val(txtCarlton.Text)) + (killburn * Val(txtKillburn.Text)) + _
            (lagos * Val(txtLagos.Text)) + (boston * Val(txtBoston.Text)) + (black * Val(txtBlack.Text)) + _
            (red * Val(txtRed.Text)) + (coffee * Val(txtCoffee.Text))
        txtDrinks.Text = FormatNumber(costdrinks)
        txtCakes.Text = FormatNumber(costcakes)
        servicecharge = 35.95
        txtCharge.Text = servicecharge
        Dim stotal As Double
        stotal = FormatNumber(Convert.ToDouble(txtDrinks.Text) + Convert.ToDouble(txtCakes.Text) + Convert.ToDouble(servicecharge))
        txtSubTotal.Text = FormatNumber(stotal)
        txtTax.Text = FormatNumber(stotal * tax)
        txtAmount.Text = FormatNumber(stotal + Convert.ToDouble(txtTax.Text))
    End Sub
   
Button btnCancel - Code

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        If MsgBox("Are you sure to CANCEL your Order?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
            Call Clear()
            rtfReceipt.Clear()
            txtCash.Text = "0.00"
            txtChange.Text = "0.00"
            Panel1.Visible = False
        Else
            Exit Sub
        End If
    End Sub

After you are going to add a ToolStrip, find and click the upper right arrow by selecting the ToolStrip, refer to the image below.


Then click the Edit Items
Add 4 Buttons and 2 Separator in the list

You need to change Text Property and Name Property of each 4 buttons



Adding a TabControl.



Inside the TabControl, Add a RichTextBox, Name it as rtfReceipt in Name Property



Next is Adding a Panel, inside the panel Add GroupBox then Add 3 Labels, 2 TextBox, 1 Button

Labels 1, 2 & 3                                                            Button
Text Property                                                  Name Property           Text Property
CASH:                                                              btnOk                          OK
CHANGE:
x


TextBox 1 & 2
Name Property           Text Property
txtCash                        0.00
txtChange                    0.00

Refer to the image.

Button btnClear - Code

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        Call Clear()
        rtfReceipt.Clear()
        txtCash.Text = "0.00"
        txtChange.Text = "0.00"
        Panel1.Visible = False
    End Sub

Button btnPay - Code

    Private Sub btnPay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPay.Click
        Panel1.Visible = True
        GroupBox3.Visible = True
        txtCash.Focus()
        txtCash.SelectionStart = 0
        txtCash.SelectionLength = Len(txtCash.Text)
    End Sub

Label Label11 – Code(Label11 is the “X” in the right side of payment panel)

    Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label11.Click
        Panel1.Visible = False
        GroupBox3.Visible = False
    End Sub

Button btnOk – Code

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        If Val(txtChange.Text) >= 0.0 Then
            rtfReceipt.Clear()
            rtfReceipt.AppendText(vbTab + vbTab + vbTab + "Wake Up Cafe" + Environment.NewLine)
            rtfReceipt.AppendText("=======================================================" + Environment.NewLine)
            rtfReceipt.AppendText("*************************************D*R*I*N*K*S*******************************" + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Iced-Cappucino" + vbTab + vbTab + vbTab + vbTab + txtIceCapp.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "American Coffee" + vbTab + vbTab + vbTab + vbTab + txtAmerica.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "African Coffee" + vbTab + vbTab + vbTab + vbTab + txtAfrica.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Vales Coffee" + vbTab + vbTab + vbTab + vbTab + txtVales.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Cappucino" + vbTab + vbTab + vbTab + vbTab + txtCapp.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Iced-Latte" + vbTab + vbTab + vbTab + vbTab + txtIcedLatte.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Espresso" + vbTab + vbTab + vbTab + vbTab + vbTab + txtEspresso.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Latte" + vbTab + vbTab + vbTab + vbTab + vbTab + txtLatte.Text + Environment.NewLine)
            rtfReceipt.AppendText("*************************************C*A*K*E*S*********************************" + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Queens Park " + vbTab + vbTab + vbTab + vbTab + txtQueen.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Carlton Hill" + vbTab + vbTab + vbTab + vbTab + txtCarlton.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Killburn" + vbTab + vbTab + vbTab + vbTab + vbTab + txtKillburn.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Lagos" + vbTab + vbTab + vbTab + vbTab + vbTab + txtLagos.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Boston" + vbTab + vbTab + vbTab + vbTab + vbTab + txtBoston.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Black" + vbTab + vbTab + vbTab + vbTab + vbTab + txtBlack.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Red" + vbTab + vbTab + vbTab + vbTab + vbTab + txtRed.Text + Environment.NewLine)
            rtfReceipt.AppendText(vbTab + "Coffee" + vbTab + vbTab + vbTab + vbTab + vbTab + txtCoffee.Text + Environment.NewLine)
            rtfReceipt.AppendText("=======================================================" + Environment.NewLine)
            rtfReceipt.AppendText("Service Charge:" + vbTab + vbTab + vbTab + vbTab + vbTab + txtCharge.Text + Environment.NewLine)
            rtfReceipt.AppendText("=======================================================" + Environment.NewLine + Environment.NewLine)
            rtfReceipt.AppendText("Tax:" + vbTab + vbTab + vbTab + vbTab + vbTab + vbTab + txtTax.Text + Environment.NewLine)
            rtfReceipt.AppendText("Sub Total:" + vbTab + vbTab + vbTab + vbTab + vbTab + txtSubTotal.Text + Environment.NewLine)
            rtfReceipt.AppendText("Total Amount" + vbTab + vbTab + vbTab + vbTab + vbTab + txtAmount.Text + Environment.NewLine)
            rtfReceipt.AppendText("=======================================================" + Environment.NewLine + Environment.NewLine)
            rtfReceipt.AppendText("Cash: " + vbTab + vbTab + vbTab + vbTab + vbTab + vbTab + FormatNumber(Val(txtCash.Text)) + Environment.NewLine)
            rtfReceipt.AppendText("Change:" + vbTab + vbTab + vbTab + vbTab + vbTab + vbTab + FormatNumber(txtChange.Text) + Environment.NewLine)
            rtfReceipt.AppendText("=======================================================" + Environment.NewLine)
            rtfReceipt.AppendText("Time: " + TimeOfDay + vbTab + vbTab + vbTab + vbTab + "Date: " + DateString + Environment.NewLine)
            Panel1.Visible = False
        Else
            MsgBox("Insufficient Cash, Try Again!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Warning")
            txtCash.SelectionStart = 0
            txtCash.SelectionLength = Len(txtCash.Text)
            Exit Sub
        End If
    End Sub


TextBox txtCash_Keypress – Code

Private Sub txtCash_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCash.KeyPress
        If Asc(e.KeyChar) = 13 Then
            e.Handled = True
            btnOk_Click(sender, e)
        Else
            e.Handled = False
        End If
    End Sub

TextBox txtCash_TextChanged – Code

    Private Sub txtCash_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCash.TextChanged
        On Error Resume Next
        txtChange.Text = FormatNumber((txtCash.Text) - (txtAmount.Text))
    End Sub


ToolStrip – Code

For Print 
Private Sub PrintToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripButton.Click
        PrintPreviewDialog1.Document = PrintDocument1
        PrintPreviewDialog1.ShowDialog()
    End Sub

For PrintDocument  
    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        e.Graphics.DrawString(rtfReceipt.Text, New Font("Arial", 14, FontStyle.Regular), Brushes.Black, 120, 120)
    End Sub

For New  
    Private Sub NewToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripButton.Click
        rtfReceipt.Clear()
    End Sub

For Open  
    Private Sub OpenToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripButton.Click
        OpenFileDialog1.FileName = "Text Files (*.txt)|*.txt|All files (*.*)|*.*"
        If (OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
            rtfReceipt.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)
        End If
    End Sub

For Save  
    Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
        SaveFileDialog1.Filter = "TEXT Files (*.txt*|*.txt"
        If SaveFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
            My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, rtfReceipt.Text, True)
        End If
    End Sub

YOUR FINAL OUTPUT – Overall appearance or design of your program may vary.
Congratulations! and Enjoy, Happy coding!


Creating a Simple Coffee Ordering System Creating a Simple Coffee Ordering System Reviewed by code-dev on 8:14 PM Rating: 5

No comments:

Powered by Blogger.