Programming with Microsoft Visual Basic 2015 (MindTap Course List)
Programming with Microsoft Visual Basic 2015 (MindTap Course List)
7th Edition
ISBN: 9781285860268
Author: Diane Zak
Publisher: Cengage Learning
Question
Book Icon
Chapter 3.LB, Problem 3E
Program Plan Intro

Cranston Berries

Create a Visual Basic Windows Application:

  • Open Microsoft Visual Basic 2010.
  • Click “File” Menu -> “New Project”.
  • In the New Project pop-up window, select the “Windows Form Application” and give the name as “Cranston Project”, and specify the location as “\VB2015\Chap01\”.

Form Design:

  • Design the main form and print form by placing the labels, textbox, and button and then change their name and properties.
  • Inside the “Calculate” button,
    • Calculate the projected sales.
  • Inside the “Print” button,
    • Print the form data.
  • Inside the “Clear” button,
    • Clear the screen.
  • Inside the “Exit” button,
    • Close the form.

Screenshot of the form design

Programming with Microsoft Visual Basic 2015 (MindTap Course List), Chapter 3.LB, Problem 3E , additional homework tip  1

Expert Solution & Answer
Check Mark

Explanation of Solution

Program:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

Partial Class frmMain

    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.

    <System.Diagnostics.DebuggerNonUserCode()> _

    Protected Overrides Sub Dispose(ByVal disposing As Boolean)

        Try

            If disposing AndAlso components IsNot Nothing Then

                components.Dispose()

            End If

        Finally

            MyBase.Dispose(disposing)

        End Try

    End Sub

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer. 

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

        Me.components = New System.ComponentModel.Container()

        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))

        Me.Label1 = New System.Windows.Forms.Label()

        Me.Label2 = New System.Windows.Forms.Label()

        Me.Label3 = New System.Windows.Forms.Label()

        Me.Label4 = New System.Windows.Forms.Label()

        Me.txtProjIncrease = New System.Windows.Forms.TextBox()

        Me.txtStraw = New System.Windows.Forms.TextBox()

        Me.txtBlue = New System.Windows.Forms.TextBox()

        Me.txtRasp = New System.Windows.Forms.TextBox()

        Me.Label5 = New System.Windows.Forms.Label()

        Me.Label6 = New System.Windows.Forms.Label()

        Me.lblStraw = New System.Windows.Forms.Label()

        Me.lblBlue = New System.Windows.Forms.Label()

        Me.lblRasp = New System.Windows.Forms.Label()

        Me.btnCalc = New System.Windows.Forms.Button()

        Me.btnPrint = New System.Windows.Forms.Button()

        Me.btnClear = New System.Windows.Forms.Button()

        Me.btnExit = New System.Windows.Forms.Button()

        Me.PrintForm1 = New Microsoft.VisualBasic.PowerPacks.Printing.PrintForm(Me.components)

        Me.SuspendLayout()

        '

        'Label1

        '

        Me.Label1.AutoSize = True

        Me.Label1.Location = New System.Drawing.Point(27, 26)

        Me.Label1.Name = "Label1"

        Me.Label1.Size = New System.Drawing.Size(268, 20)

        Me.Label1.TabIndex = 0

        Me.Label1.Text = "Projected &increase % (in decimal form):"

        '

        'Label2

        '

        Me.Label2.AutoSize = True

        Me.Label2.Location = New System.Drawing.Point(27, 108)

        Me.Label2.Name = "Label2"

        Me.Label2.Size = New System.Drawing.Size(94, 20)

        Me.Label2.TabIndex = 2

        Me.Label2.Text = "&Strawberries:"

        '

        'Label3

        '

        Me.Label3.AutoSize = True

        Me.Label3.Location = New System.Drawing.Point(27, 157)

        Me.Label3.Name = "Label3"

        Me.Label3.Size = New System.Drawing.Size(86, 20)

        Me.Label3.TabIndex = 4

        Me.Label3.Text = "&Blueberries:"

        '

        'Label4

        '

        Me.Label4.AutoSize = True

        Me.Label4.Location = New System.Drawing.Point(27, 203)

        Me.Label4.Name = "Label4"

        Me.Label4.Size = New System.Drawing.Size(89, 20)

        Me.Label4.TabIndex = 6

        Me.Label4.Text = "&Raspberries:"

        '

        'txtProjIncrease

        '

        Me.txtProjIncrease.Location = New System.Drawing.Point(301, 23)

        Me.txtProjIncrease.Name = "txtProjIncrease"

        Me.txtProjIncrease.Size = New System.Drawing.Size(57, 27)

        Me.txtProjIncrease.TabIndex = 1

        '

        'txtStraw

        '

        Me.txtStraw.Location = New System.Drawing.Point(122, 105)

        Me.txtStraw.Name = "txtStraw"

        Me.txtStraw.Size = New System.Drawing.Size(100, 27)

        Me.txtStraw.TabIndex = 3

        '

        'txtBlue

        '

        Me.txtBlue.Location = New System.Drawing.Point(122, 154)

        Me.txtBlue.Name = "txtBlue"

        Me.txtBlue.Size = New System.Drawing.Size(100, 27)

        Me.txtBlue.TabIndex = 5

        '

        'txtRasp

        '

        Me.txtRasp.Location = New System.Drawing.Point(122, 200)

        Me.txtRasp.Name = "txtRasp"

        Me.txtRasp.Size = New System.Drawing.Size(100, 27)

        Me.txtRasp.TabIndex = 7

        '

        'Label5

        '

        Me.Label5.AutoSize = True

        Me.Label5.Location = New System.Drawing.Point(118, 78)

        Me.Label5.Name = "Label5"

        Me.Label5.Size = New System.Drawing.Size(95, 20)

        Me.Label5.TabIndex = 12

        Me.Label5.Text = "Current Sales"

        '

        'Label6

        '

        Me.Label6.AutoSize = True

        Me.Label6.Location = New System.Drawing.Point(254, 78)

        Me.Label6.Name = "Label6"

        Me.Label6.Size = New System.Drawing.Size(110, 20)

        Me.Label6.TabIndex = 13

        Me.Label6.Text = "Projected Sales"

        '

        'lblStraw

        '

        Me.lblStraw.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Me.lblStraw.Location = New System.Drawing.Point(258, 105)

        Me.lblStraw.Name = "lblStraw"

        Me.lblStraw.Size = New System.Drawing.Size(100, 27)

        Me.lblStraw.TabIndex = 14

        Me.lblStraw.TextAlign = System.Drawing.ContentAlignment.MiddleRight

        '

        'lblBlue

        '

        Me.lblBlue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Me.lblBlue.Location = New System.Drawing.Point(258, 154)

        Me.lblBlue.Name = "lblBlue"

        Me.lblBlue.Size = New System.Drawing.Size(100, 27)

        Me.lblBlue.TabIndex = 15

        Me.lblBlue.TextAlign = System.Drawing.ContentAlignment.MiddleRight

        '

        'lblRasp

        '

        Me.lblRasp.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle

        Me.lblRasp.Location = New System.Drawing.Point(258, 200)

        Me.lblRasp.Name = "lblRasp"

        Me.lblRasp.Size = New System.Drawing.Size(100, 27)

        Me.lblRasp.TabIndex = 16

        Me.lblRasp.TextAlign = System.Drawing.ContentAlignment.MiddleRight

        '

        'btnCalc

        '

        Me.btnCalc.Location = New System.Drawing.Point(17, 261)

        Me.btnCalc.Name = "btnCalc"

        Me.btnCalc.Size = New System.Drawing.Size(81, 29)

        Me.btnCalc.TabIndex = 8

        Me.btnCalc.Text = "&Calculate"

        Me.btnCalc.UseVisualStyleBackColor = True

        '

        'btnPrint

        '

        Me.btnPrint.Location = New System.Drawing.Point(110, 261)

        Me.btnPrint.Name = "btnPrint"

        Me.btnPrint.Size = New System.Drawing.Size(81, 29)

        Me.btnPrint.TabIndex = 9

        Me.btnPrint.Text = "&Print"

        Me.btnPrint.UseVisualStyleBackColor = True

        '

        'btnClear

        '

        Me.btnClear.Location = New System.Drawing.Point(203, 261)

        Me.btnClear.Name = "btnClear"

        Me.btnClear.Size = New System.Drawing.Size(81, 29)

        Me.btnClear.TabIndex = 10

        Me.btnClear.Text = "C&lear"

        Me.btnClear.UseVisualStyleBackColor = True

        '

        'btnExit

        '

        Me.btnExit.Location = New System.Drawing.Point(296, 261)

        Me.btnExit.Name = "btnExit"

        Me.btnExit.Size = New System.Drawing.Size(81, 29)

        Me.btnExit.TabIndex = 11

        Me.btnExit.Text = "E&xit"

        Me.btnExit.UseVisualStyleBackColor = True

        '

        'PrintForm1

        '

        Me.PrintForm1.DocumentName = "document"

        Me.PrintForm1.Form = Me

        Me.PrintForm1.PrintAction = System.Drawing.Printing.PrintAction.PrintToPreview

        Me.PrintForm1.PrinterSettings = CType(resources.GetObject("PrintForm1.PrinterSettings"), System.Drawing.Printing.PrinterSettings)

        Me.PrintForm1.PrintFileName = Nothing

        '

        'frmMain

        '

        Me.AutoScaleDimensions = New System.Drawing.SizeF(8!, 20!)

        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

        Me.ClientSize = New System.Drawing.Size(392, 314)

        Me.Controls.Add(Me.btnExit)

        Me.Controls.Add(Me.btnClear)

        Me.Controls.Add(Me.btnPrint)

        Me.Controls.Add(Me.btnCalc)

        Me.Controls.Add(Me.lblRasp)

        Me.Controls.Add(Me.lblBlue)

        Me.Controls.Add(Me.lblStraw)

        Me.Controls.Add(Me.Label6)

        Me.Controls.Add(Me.Label5)

        Me.Controls.Add(Me.txtRasp)

        Me.Controls.Add(Me.txtBlue)

        Me.Controls.Add(Me.txtStraw)

        Me.Controls.Add(Me.txtProjIncrease)

        Me.Controls.Add(Me.Label4)

        Me.Controls.Add(Me.Label3)

        Me.Controls.Add(Me.Label2)

        Me.Controls.Add(Me.Label1)

        Me.Font = New System.Drawing.Font("Segoe UI", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0,Byte))

        Me.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)

        Me.Name = "frmMain"

        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

        Me.Text = "Cranston Berries"

        Me.ResumeLayout(false)

        Me.PerformLayout

End Sub

    Friend WithEvents Label1 As Label

    Friend WithEvents Label2 As Label

    Friend WithEvents Label3 As Label

    Friend WithEvents Label4 As Label

    Friend WithEvents txtProjIncrease As TextBox

    Friend WithEvents txtStraw As TextBox

    Friend WithEvents txtBlue As TextBox

    Friend WithEvents txtRasp As TextBox

    Friend WithEvents Label5 As Label

    Friend WithEvents Label6 As Label

    Friend WithEvents lblStraw As Label

    Friend WithEvents lblBlue As Label

    Friend WithEvents lblRasp As Label

    Friend WithEvents btnCalc As Button

    Friend WithEvents btnPrint As Button

    Friend WithEvents btnClear As Button

    Friend WithEvents btnExit As Button

    Friend WithEvents PrintForm1 As PowerPacks.Printing.PrintForm

End Class

Sample Output
  • Run the program, by pressing the F5.

    Screenshot of the output form

Programming with Microsoft Visual Basic 2015 (MindTap Course List), Chapter 3.LB, Problem 3E , additional homework tip  2

Screenshot of Calculate

Programming with Microsoft Visual Basic 2015 (MindTap Course List), Chapter 3.LB, Problem 3E , additional homework tip  3

Screenshot of Print Preview

Programming with Microsoft Visual Basic 2015 (MindTap Course List), Chapter 3.LB, Problem 3E , additional homework tip  4

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Change the following code so that it checks the following 3 conditions: 1. there is no space between each cells (imgs) 2. even if it is resized, the components wouldn't disappear 3. The GameGUI JPanel takes all the JFrame space, so that there shouldn't be extra space appearing in the frame other than the game.   Main():         Labyrinth labyrinth = new Labyrinth(10);         Player player = new Player(9, 0);        Dragon dragon = new Dragon(9, 9);         JFrame frame = new JFrame("Labyrinth Game");        GameGUI gui = new GameGUI(labyrinth, player, dragon);         frame.add(gui);        frame.setSize(600, 600);        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setVisible(true);   public class GameGUI extends JPanel {    private final Labyrinth labyrinth;    private final Player player;    private final Dragon dragon; //labyrinth, player, dragon are just public classes     private final ImageIcon playerIcon = new ImageIcon("data/images/player.png");…
Make the following game user friendly with GUI, with some simple graphics. The GUI should be in another seperate class, with some ImageIcon, and Game class should be added into the pane. The following code works as this: The objective of the player is to escape from this labyrinth. The player starts at the bottom left corner of the labyrinth. He has to get to the top right corner of the labyrinth as fast he can, avoiding a meeting with the evil dragon. The player can move only in four directions: left, right, up or down. There are several escape paths in all labyrinths. The player’s character should be able to moved with the well known WASD keyboard buttons. If the dragon gets to a neighboring field of the player, then the player dies. Because it is dark in the labyrinth, the player can see only the neighboring fields at a distance of 3 units.  Cell Class: public class Cell { private boolean isWall; public Cell(boolean isWall) { this.isWall = isWall; } public boolean isWall() { return…
Discuss the negative and positive impacts or information technology in the context of your society. Provide two references along with with your answer

Chapter 3 Solutions

Programming with Microsoft Visual Basic 2015 (MindTap Course List)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT