Drink Vending Machine Code - vb.net

Hello Stackflow community,
I'm currently taking a class in Visual Basic and I'm in need of some assistance. I am creating a program that simulates a Drink Vending Machine using an array. The instructions follow:
Create an application that simulates a soft-drink vending machine. The application should let the user select one of the following soft drinks:
Cola ($1.00 each)
Root Beer ($1.00 each)
Lemon Lime Soda ($1.00 each)
Grape Soda ($1.50 each)
Cream Soda ($1.50 each)
When the application starts, the vending machine will have 20 of each type of soft drink. Each time the user selects a drink, the application should subtract 1 from the quantity of the selected drink. It should also update and display the total amount of sales. If the user selects a drink that is sold out, a message should be displayed indicating so.
In the application’s code, create a structure that has fields for the following data:
Drink name
Drink cost
Number of drinks in machine
The program should create an array of five structure objects. Each element of the array should keep data for a specific type of soft drink.
I can't figure out how to make my buttons work to decrement the quantity labels and then add each click to the label total. Please help.
Public Class Form1
' Class-level declarations
Const intMAX_SUBSCRIPT As Integer = 4 ' Upper subscript
Dim strProdNames(intMAX_SUBSCRIPT) As String ' Product Names
Dim decPrice(intMAX_SUBSCRIPT) As Decimal ' Drink Price
Dim intProdNums(intMAX_SUBSCRIPT) As Integer ' Product Numbers
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Initialize the arrays with the product data.
InitArrays()
End Sub
Private Sub InitArrays()
' Initialize the arrays.
' First Product
strProdNames(0) = "Cola"
decPrice(0) = 1D
intProdNums(0) = 20
' Second Product
strProdNames(1) = "Root Beer"
decPrice(1) = 1D
intProdNums(1) = 20
' Third Product
strProdNames(2) = "Lemon Lime"
decPrice(2) = 1D
intProdNums(2) = 20
' Fourth Product
strProdNames(3) = "Grape Soda"
decPrice(3) = 1.5D
intProdNums(3) = 20
' Fifth Product
strProdNames(4) = "Cream Soda"
decPrice(4) = 1.5D
intProdNums(4) = 20
End Sub
Private Sub btnCola_Click(sender As Object, e As EventArgs) Handles btnCola.Click
Dim intCount As Integer = 20 ' Loop Counter
intCount -= 1 ' Decrement drink count
If intCount > 0 Then
lblTotal.Text = decPrice(0).ToString("c")
End If
End Sub

You need to decrement the cola count, which is in the array.
Private Sub btnCola_Click(sender As Object, e As EventArgs)
If intProdNums(0) > 0 Then
intProdNums(0)-=1 ' decrement cola drink count
End If
' show results here...
End Sub

Related

How to add the sum in the listbox(visual basic) mix with other value, the value should get it price number

from combobox to the dish i used if statement to display my dish in my dish area,
from dish to the list i used:
Dim quantity As Integer
quantity = txtQuantity.Text
If lstDish.SelectedIndex > -1 Then
Dim index1 As Integer
index1 = lstDish.SelectedIndex
Dim item1 As Object
item1 = lstDish.SelectedItem
lstList.Items.Add(item1 & " --> " & quantity)
End If
txtQuantity.Text = 1
The value display at list are will be in form Noodle -> 2
What should i do to get the noodle value as 3.50 * my quantity 2 and add all my sum for the list
Dim Total As Integer
Dim priceOfDish As String = 0
Dim quantity As Integer
Dim friesPrice, garlicBreadPrice, friedChickenWingPrice, springRollPrice As Double
Dim chickenRicePrice, friedRicePrice, curryRicePrice, thaiChickenRice As Double
Dim friedSeafoodNoodlePrice, chickenNoodlePrice, beefNoodlePrice, prawnNoodlePrice As Double
Select Case priceOfDish
Case Is = "Fries"
friesPrice += 2.5
Case Is = "Garlic Bread"
garlicBreadPrice += 2.5
Case Is = "Fried Chicken Wing"
friedChickenWingPrice += 2.5
Case Is = "Spring Roll"
springRollPrice += 2.5
Case Is = "Chicken Rice"
chickenRicePrice += 4
Case Is = "Fried Rice"
friedRicePrice += 4
Case Is = "Curry Rice"
curryRicePrice += 4
Case Is = "Thai Chicken Rice"
thaiChickenRice += 4
Case Is = "Fried Seafood Noodle"
friedSeafoodNoodlePrice += 3.5
Case Is = "Chicken Noodle"
chickenNoodlePrice += 3.5
Case Is = "Beef Noodle"
beefNoodlePrice += 3.5
Case Is = "Prawn Noodle"
prawnNoodlePrice += 3.5
End Select
Total = priceOfDish * quantity
txtTotal.Text = Total
End Sub
code for the total button
I have only included the code to demonstrate one method of getting the total. As several others have mentioned, a Class is probably the best method but I don't think you have reached the use of classes in your course yet.
I have declared 2 form level variables to hold values that can be accessed from more than one method. They do not lose their values at the end of a Sub but maintain them as long as the Form is open. You will need to reset the RunningTotal button to 0 in your Clear button.
When the user selects a category the code resets the value of CategoryCost is set so it is ready if the user chooses to add an item form this category. It is reset every time a new category is chosen.
It is then a simple matter to calculate the cost and add it to the RunningTotal in the AddButton. Then it is displayed in the txtTotal by calling .ToString with the "C2" parameter which stands for Currency with 2 numbers after the decimal point.
Private RunningTotal As Decimal
Private CategoryCost As Decimal
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim Category = ComboBox1.Text
Select Case Category
'Add your code to display the products in each category in the left hand list box
Case "Snack"
CategoryCost = 2.5D
Case "Noodle"
CategoryCost = 3.5D
Case "Rice"
CategoryCost = 4D
Case Else
CategoryCost = 0D
End Select
End Sub
Private Sub AddButton_Click(sender As Object, e As EventArgs) Handles AddButton.Click
'Your code to display the selected item from the left list box in the right list box
'can be entered here.
RunningTotal += CDec(txtQuantity.Text) * CategoryCost
'If you don't want to display a running total, put the following code in a total button
txtTotal.Text = RunningTotal.ToString("C2")
End Sub
You can create a database for store products and a table for products
By this query
Put like this query on button click event
Declare #sum as integer=0
Select #sum=product_cost * “+val(textboxcount.text)+” from product_table where product_name=“+listbox.selelcttext+” <—-listbox selected
Declare a variable in the form and do your calculation in the Add Button (Not Total Button)
Public Class MyForm
dim MyTotal as Double
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
' Do your stuff to move from dishes to the list
MyTotal = MyTotal + (cdbl(txtQuantity.Text) * Price)
End Sub
Private Sub btnTotal_Click(sender As Object, e As EventArgs) Handles btnTotal.Click
txt_Total.text = MyTotal.ToString("N2")
End Sub
End Class

How to display the labels for this Microsoft Visual Studio code?

I'm currently taking a basic Microsoft Visual Studio 2017 course. The question asks me to import and read the contents from a text file to calculate and display the energy cost savings for a smart home. I am stuck starting on the comment, ' The formula for the average monthly savings inside the loop to repeat the process' on line 96 where I am supposed to calculate the average formula for the energy savings. I would also like to know how I can display the three labels. The name of the text formula is savings.txt. These are its contents:
January
38.17
February
41.55
March
27.02
April
25.91
May
3.28
June
18.08
July
45.66
August
16.17
September
3.98
October
17.11
November
25.78
December
51.03
Are there any additional changes I can make to improve my code? I am new to this course and welcome any suggestions or examples.
Here is also a link to my rubric. Please let me know if you cannot access its contents:
https://maricopa-my.sharepoint.com/:w:/g/personal/ric2084617_maricopa_edu/ETNr_-i-wllOr9zsRiNTyMIBG0CcNO1xICcaYVYmgKl7YA?e=tLq4Ng
I am certain I have the required variables declared. I am at a loss of how to apply them into the average formula. Should I add each of the costs from the text file or is there a more simple yet basic method to add them?
' Program Name: Smart Home Electric Savings
' Author: Richard Lew
' Date: October 27, 2019
' Purpose: This Windows application opens a text file that lists the monthly savings of a smart home's electric bill in comparison to a previous year
' without smart device activation. A smart thermostat, lighting system, and water heater were installed one year ago and the text file lists
' the savings each month. The The user selects a month read from the text file and displays that month's electric bill savings. A Button object
' displays the average monthly savings with the smart home devices and the month with the most significant savings.
Option Strict On
Public Class frmSavings
' Class Level Private variables
Private _intMonthsOfSmartSavings As Integer = 12
Public Shared _intSizeOfArray As Integer = 7
Public Shared _strSavings(_intSizeOfArray) As String
Private _strSavingsMonth(_intSizeOfArray) As String
Private _decInitialBill(_intSizeOfArray) As Decimal
Private _intMonth(_intSizeOfArray) As Integer
Private Sub fromSavings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' The frmSavings load event reads the savings text file and fills the label objects with the savings.
' Initialize an instance of the StreamReader object and declare variables
Dim objReader As IO.StreamReader
Dim strLocationAndNameOfFile As String = "D:\CIS 159\VB_Student_Data_Files\Chapter 8\savings.txt"
Dim intCount As Integer = 0
Dim intFill As Integer
Dim strFileError As String = "The file is not available. Restart when the file is available."
' Verify the file exists
If IO.File.Exists(strLocationAndNameOfFile) Then
objReader = IO.File.OpenText(strLocationAndNameOfFile)
' Read the file line by line until the file is completed
Do While objReader.Peek <> -1
_strSavings(intCount) = objReader.ReadLine()
_strSavingsMonth(intCount) = objReader.ReadLine()
_decInitialBill(intCount) = Convert.ToDecimal(objReader.ReadLine())
_intMonth(intCount) = Convert.ToInt32(objReader.ReadLine())
intCount += 1
Loop
objReader.Close()
' The Monthly Savings Combo Box object is filled with the months of the savings
For intFill = 0 To (_strSavingsMonth.Length - 1)
cboMonthSavings.Items.Add(_strSavingsMonth(intFill))
Next
Else
MsgBox(strFileError, , "Error")
Close()
End If
End Sub
Private Sub BtnDisplayStatistics_Click(sender As Object, e As EventArgs) Handles btnDisplayStatistics.Click
' The btnDisplayStatistics click event calls the savings Sub procedures
' Declare variables
Dim intSelectedMonth As Integer
Dim strMissingSelection As String = "Missing Selection"
Dim strSelectedMonthError As String = "Select a Month"
Dim strSelectedMonth As String = ""
Dim intMonthChoice As Integer
Dim blnMonthIsSelected As Boolean = False
' If the Month Savings Combo Box is selected, then display the statistics
If cboMonthSavings.SelectedIndex >= 0 Then
intSelectedMonth = cboMonthSavings.SelectedIndex
Else
MsgBox(strSelectedMonthError, , strMissingSelection)
End If
End Sub
Private Sub MonthSavingsComboBox(ByVal intMonth As Integer)
' This Sub procedure computes and displays the savings for the month selected
' Declare variables
Dim intDoublePresentMonth As Integer
Dim decDoubleAverage As Decimal = 0
Dim decDoublePresentMonthValue As Decimal = 0
Dim decDoubleSavings As Decimal
Dim decAverageSavings As Decimal
Dim decTotal As Decimal
Dim decDoubleTotal As Decimal = 0.0D
Dim strPresentSavingsMonth As String = ""
Dim strPresentSavingsMonthValue As String = ""
Dim decSavingsMonth As Decimal
Dim strMonthOfSavings As String = ""
Dim decAverageSavingsOfMonth As Decimal
Dim decSignificantSavingsOfMonth As Decimal
Dim strMonthOfSignificantSavings As String = ""
' The procedure MakeObjectsVisible is called to display the Form objects
MakeObjectsVisible()
'Display the values and quantity of the selected values
lblDisplayMonthSavings.Text = "The electric savings for " & strPresentSavingsMonth & " is " & _strSavings(intMonth)
lblDisplayAverageMonthlySavings.Text = "The average monthly savings: " & decAverageSavings.ToString("C0")
lblDisplayMonthMostSignificantSavings.Text = _decInitialBill(intMonth) & " had the most significant monthly savings"
' The loop repeats for the life of the values
For intDoublePresentMonth = 1 To _intMonthsOfSmartSavings
' The formula for the average monthly savings inside the loop to repeat the process
decAverageSavings = decDoubleTotal / _intMonthsOfSmartSavings
' Displays the savings amounts
cboMonthSavings.Items.Add(intDoublePresentMonth.ToString())
' Accumulates the total of the savings
decTotal += decDoubleSavings
Next
End Sub
Private Sub MakeObjectsVisible()
' This procedure displays the objects showing the results
lblDisplayMonthSavings.Visible = True
btnDisplayStatistics.Visible = True
lblDisplayAverageMonthlySavings.Visible = True
lblDisplayMonthMostSignificantSavings.Visible = True
' The previous data is removed
cboMonthSavings.Items.Clear()
lblDisplayMonthSavings.Text = ""
lblDisplayAverageMonthlySavings.Text = ""
lblDisplayMonthMostSignificantSavings.Text = ""
End Sub
Private Sub MnuFile_Click(sender As Object, e As EventArgs) Handles mnuFile.Click
' The mnuFile click event displays the mnuClear and and mnuExit buttons
End Sub
Private Sub MnuClear_Click(sender As Object, e As EventArgs) Handles mnuClear.Click
' The mnuClear click event clears and resets the form
cboMonthSavings.Items.Clear()
lblDisplayMonthSavings.Text = ""
lblDisplayAverageMonthlySavings.Text = ""
lblDisplayMonthMostSignificantSavings.Text = ""
lblDisplayMonthSavings.Visible = False
lblDisplayAverageMonthlySavings.Visible = False
lblDisplayMonthMostSignificantSavings.Visible = False
End Sub
Private Sub MnuExit_Click(sender As Object, e As EventArgs) Handles mnuExit.Click
' The mnuExit click event closes the application
Application.Exit()
End Sub
End Class

High Scores for game

I am trying to get a high scores including player name to display on a separate form after all lives are lost in a game. I currently have this code for the high scores form - however it is only displaying the one score in the array and I am wanting to store 10 scores and also player's names.
Imports System.IO
'Code allows the computer to read from the text file containing player scores.'
Public Class Form3
Dim highscore(9) As Integer ' array for highscores
Dim playername(9) As String
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim i, value1, value2 As Integer 'player score variables
Dim DataFile As StreamWriter
' Static save As String
value1 = lblScore.Text ' assigns the players score to value1
value2 = lblScore.Text ' assigns the players score to value2
i = 0
DataFile = New StreamWriter("D:\mmend12\My Documents\IPT\Projects\Brandon Moss - Major Project Assignment\Cosmic Crusade\Cosmic Crusade\bin\Debug\HighScore.txt")
i = 0
For i = 0 To 9
If highscore(i) < value1 Then 'checks to see if the players score is bigger than the score
value1 = highscore(i) ' assigns the value of highscore to value 1
highscore(i) = value2 'assigns the players score to the highscore
value2 = value1 ' assigns the previous highscore to value1
End If
lbxHighScores.Items.Add(highscore(i)) ' displays the scores
'lbxNames.Items.Add(playername(i))
DataFile.WriteLine(highscore(i)) ' saves the highscores to disk
' DataFile.WriteLine(playername(i))
Next
DataFile.Close()
End Sub
Private Sub btnShowScores_Click(sender As Object, e As EventArgs) Handles btnShowScores.Click
Dim DataFile As StreamReader
'Declares the variable name "DataFile" as an instance of StreamWriter, meaning that DataFile will behave like a StreamWriter object.'
'Dim J As Integer
DataFile = New StreamReader("D:\mmend12\My Documents\IPT\Projects\Brandon Moss - Major Project Assignment\Cosmic Crusade\Cosmic Crusade\bin\Debug\HighScore.txt")
'Using the file path/address written above, a test.txt file is added in this folder.'
'For J = 1 To 10
'Creates a fixed loop, that loops 10 times
For i = 0 To 9
highscore(i) = DataFile.ReadLine
lbxHighScores.Items.Add(DataFile.ReadLine)
Next
DataFile.Close()
'Closes the data file.
End Sub
I have this code in the game form after all lives are lost:
If PlayersLives = 0 Then
End If
PlayerName = InputBox("Enter your username ")
lblName.Text = PlayerName
Form3.lblScore.Text = lblScoreNumber.Text
Form3.lblPlayer.Text = lblName.Text
Can anyone provide assistance with this.
I would respectfully suggest rewriting the Form3 code as follows ..
I'm assuming that when you click on a name in the ListBox, the associated score is displayed in LblScore
Anyhow back to the code. This way, the code to save and load the scores is separated from your Load event and the code that modifies the list of high scores is also separated out. It will be easier to maintain/modify later. It's also better to manipulate data separately from controls to avoid the risk of inadvertent modification by users.
Each player and their score is now stored in instances of the class Playerand all the players are stored in a List (Of Player)called highScores
There is also now a sub called UpdateListBox which uses the highScores list as a data source. The items to display are the .Name property of each player and the value that is returned when you click on the name of a player is the score which is then assigned to lblScore without any need for looping through arrays or lists.
Public Class Form3
'Code allows the computer to read from the text file containing player scores.'
Friend Class Player
Public Property Score As Integer
Public Property Name As String
End Class
Dim highscores As New List(Of Player) ' array for highscores
Public Sub AddScoreIfHighEnough(player As String, score As Integer)
'make sure that the high score list is sorted first
highscores = highscores.OrderByDescending(Function(x) x.Score).ToList
'work down though the list
For Each plyr As Player In highscores
'if the score is higher than the current item in the list,
'insert the new score there and exit the loop
If score > plyr.Score Then
highscores.Insert(highscores.IndexOf(plyr), New Player With {.Name = player, .Score = score})
Exit For
End If
Next
highscores.Add(New Player With {.Name = player, .Score = score})
'if after the loop has completed, the number of items is
'greater than 10, remove the lowest
If highscores.Count > 10 Then
highscores.Remove(highscores.Last)
End If
UpdateListbox()
SaveScoreData()
End Sub
Private Sub SaveScoreData()
Using DataFile As New StreamWriter("D:\mmend12\My Documents\IPT\Projects\Brandon Moss - Major Project Assignment\Cosmic Crusade\Cosmic Crusade\bin\Debug\HighScore.txt")
For Each plyr As Player In highscores
DataFile.WriteLine(plyr.Name) ' saves the name to disk
DataFile.WriteLine(plyr.Score.ToString) 'saves the score
Next
End Using
End Sub
Private Sub LoadScoreData()
highscores.Clear()
Using DataFile As New StreamReader("D:\mmend12\My Documents\IPT\Projects\Brandon Moss - Major Project Assignment\Cosmic Crusade\Cosmic Crusade\bin\Debug\HighScore.txt")
While Not DataFile.EndOfStream
Dim tempPlayerScore As New Player With {
.Name = DataFile.ReadLine, ' saves the name to disk
.Score = CInt(DataFile.ReadLine) 'saves the score
}
highscores.Add(tempPlayerScore)
End While
End Using
UpdateListbox()
End Sub
Private Sub UpdateListbox()
lbxHighScores.Items.Clear()
For Each plyr As Player In highscores
lbxHighScores.Items.Add(plyr.Name & " " & plyr.Score)
Next
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LoadScoreData()
End Sub
Private Sub LbxHighScores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lbxHighScores.SelectedIndexChanged
If Not IsNothing(lbxHighScores.SelectedItem) Then
lblScore.Text = CType(lbxHighScores.SelectedItem, Player).Score.ToString
End If
End Sub
End Class
In your code to add a high score, use something like
If PlayersLives = 0 Then
End If
PlayerName = InputBox("Enter your username ")
lblName.Text = PlayerName
form3.AddScoreIfHighEnough(lblName.Text, CInt(lblScoreNumber.Text))
Form3.lblPlayer.Text = lblName.Text

Limiting the range of values allowed in multiple textboxes

For my current assignment, I've been asked to create a form to allow customers to enter desired quantities of shoes in a textbox and then total the cost in a second textbox. However, the customer cannot purchase more than 3 of any one particular shoe. I attempted to do the first two shoes in the code below but am running into issues once I added the code for the second model.
Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click
Dim qntyClassy, qntyHigh As Double
txtQntyClassy.Text = qntyClassy
txtQntyHigh.Text = qntyHigh
If 0 < Int(txtQntyClassy.Text) And Int(txtQntyClassy.Text) < 4 Then
txtTotalClassy.Text = FormatCurrency(txtQntyClassy.Text * 43)
txtQntyClassy.Text = Int(txtQntyClassy.Text)
Else
MsgBox("Enter a quantity no greater than 3.")
End If
If 0 < Int(txtQntyHigh.Text) And Int(txtQntyHigh.Text) < 4 Then
txtTotalHigh.Text = FormatCurrency(txtQntyHigh.Text * 48.95)
txtQntyHigh.Text = Int(txtQntyHigh.Text)
Else
MsgBox("Enter a quantity no greater than 3.")
End If
End Sub
End Class

Keeping Track of Totals in Visual Basic

I am trying to code an application that will keep track of the total amount of cars sold through the person's ID number. I have coded it so that the car totals show in their respective fields but how do I get it so that the totals are saved after I input more ID numbers. The below is the ID requirements.
The first number can be either 1 or 2. 1 is new cars sold while 2 is used cars sold.
The last letter of the ID is P (Part time) or F (Full Time).
The setup is like this:
ID: Number of cars sold:
(Textbox to input ID#) (Textbox to input number of cars sold)
Calculate Button Exit Button
Total of cars sold by full-time employees: (label to display total)
Total of cars sold by part-time employees: (label to display total)
Total of new cars sold: (label to display total)
Total of used cars sold: (label to display total)
Here's my code. I want to keep a running total for each depending on the input ID number. So if I put it 1MBP sold 7 cars and 1DKP sold 7 cars, the totals for new cars and part-time employee should show 14
' Name: Huntington Motors Sales Application
' Purpose: The application will calculate the number and type of cars sold as per
' input from the manager. The ID number specifies the type of sales person
' sold the car which is how the application will calculate the total.
' Programmer: Marlinda Davis on October 15, 2015
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
Dim strId As String
Dim intNumSold As Integer
Dim intNew As Integer
Dim intUsed As Integer
Dim intPartTime As Integer
Dim intFullTime As Integer
' identify characters in ID '
strId = txtIDNum.Text.Trim.ToUpper
Integer.TryParse(txtNumSold.Text, intNumSold)
' verify that the ID contains a number followed by 3 numbers
' The first number 1 = new car sales person or 2 = used car sales person
' The next two letters are the person's initials
' The last letter indicates if the person is full time(F) or part time(P)
If strId Like "[12][A-Z][A-Z][FP]" Then
If strId.Substring(0) = "1" Then
intNew = intNew + intNumSold
lblNewNum.Text = intNew.ToString
Else
intUsed = intUsed + intNumSold
lblUsedNum.Text = intUsed.ToString
End If
If strId.Substring(3) = "F" Then
intFullTime = intFullTime + intNumSold
lblFTNum.Text = intFullTime.ToString
Else
intPartTime = intPartTime + intNumSold
lblPTNum.Text = intPartTime.ToString
End If
End If
' refocus on ID input box after each entry '
txtIDNum.Focus()
txtIDNum.SelectAll()
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Const strEXIT As String = "Are you sure you want to close this application?"
Dim dlgExit As DialogResult
' verify the user wants to close the application '
dlgExit = MessageBox.Show(strEXIT, "Huntington Motors", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation)
' if the user answers No then the application will not close '
If dlgExit = System.Windows.Forms.DialogResult.No Then
e.Cancel = True
End If
End Sub
End Class