How to implement a vending machine? - winforms

For a school project I have been asked to create a virtual vending machine in a windows form application using visual basic. I am around 80% complete but I have a few of problems that I have researched multiple times but still cannot find help.
Firstly, on the vending machine when I purchase an item if the credit left over (change) is less than the products originals price it will display an error message saying you do not have enough credit to buy the product. How do I make it so it only displays that message if the credit is not enough to buy the product before-hand and not straight away after the purchase?
Secondly, how would I go about making a system for the credit left over after the purchase, as at the moment I have only got a credit return button which the user would use to extract the remaining credit left over after the purchase, instead of a system for giving out change.
Finally, how would I make it so the user is not allowed to enter text into a text-box as the vending machine uses two text box's, one to display credit and the other to display other general messages such as to clarify that you have bought a certain product or that you do not have enough credit to purchase a certain product.
Here is my code so far:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
RichTextBox1.Text = "You Have Selected Galaxy Caramel, Please Insert 60p"
If credit >= 60 Then RichTextBox1.Text = "Thank you for purchasing a Galaxy Caramel bar"
credit = credit - 60
TextBox1.Text = credit
If credit < 60 Then RichTextBox1.Text = "You do not have enough credit to purchase a Galaxy Caramel Bar"
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
RichTextBox1.Text = "You Have Selected Cadburys Milk Chocolate, Please Insert 75p"
If credit >= 75 Then RichTextBox1.Text = "Thank you for purchasing a Cadburys Milk Chocolate Bar"
credit = credit - 75
TextBox1.Text = credit
If credit < 75 Then RichTextBox1.Text = "You do not have enough credit to purchase a Cadburys Milk Chocolate Bar"
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
RichTextBox1.Text = "You Have Selected Bounty, Please Insert 70p"
If credit >= 70 Then RichTextBox1.Text = "Thank you for purchasing a Bounty bar"
credit = credit - 70
TextBox1.Text = credit
If credit < 70 Then RichTextBox1.Text = "You do not have enough credit to purchase a Bounty Bar"
End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
RichTextBox1.Text = "You Have Selected Yorkie, Please Insert 60p"
If credit >= 60 Then RichTextBox1.Text = "Thank you for purchasing a Yorkie bar"
credit = credit - 60
TextBox1.Text = credit
If credit < 60 Then RichTextBox1.Text = "You do not have enough credit to purchase a Yorkie Bar"
End Sub
Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
RichTextBox1.Text = "You Have Selected Doritos Tangy Cheese, Please Insert 85p"
If credit >= 85 Then RichTextBox1.Text = "Thank you for purchasing Doritos Tangy Cheese Crisps"
credit = credit - 85
TextBox1.Text = credit
If credit < 85 Then RichTextBox1.Text = "You do not have enough credit purchase Doritos Tangy Cheese Crisps"
End Sub
Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
RichTextBox1.Text = "You Have Selected Doritos Cool Original, Please Insert 75p"
If credit >= 75 Then RichTextBox1.Text = "Thank you for purchasing Doritos Cool Original Crisps"
credit = credit - 75
TextBox1.Text = credit
If credit < 75 Then RichTextBox1.Text = "You do not have enough credit to purchase Doritos Cool Original Crisps"
End Sub
Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
RichTextBox1.Text = "You Have Selected Walkers Cheese & Onion, Please Insert 70p"
If credit >= 70 Then RichTextBox1.Text = "Thank you for purchasing Walkers Cheese & Onion Crisps"
credit = credit - 70
TextBox1.Text = credit
If credit < 70 Then RichTextBox1.Text = "You do not have enough credit to purchase Walkers Cheese & Onion Crisps"
End Sub
Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
RichTextBox1.Text = "You Have Selected Mccoy's Cheddar, Please Insert 80p"
If credit >= 80 Then RichTextBox1.Text = "Thank you for purchasing Mccoy's Cheddar Crisps"
credit = credit - 80
TextBox1.Text = credit
If credit < 80 Then RichTextBox1.Text = "You do not have enough credit to purchase Mccoy's Cheddar Crisps"
End Sub
Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button9.Click
RichTextBox1.Text = "You Have Selected Pepsi Max, Please Insert £1.10"
If credit >= 110 Then RichTextBox1.Text = "Thank you for purchasing Pepsi Max"
credit = credit - 110
TextBox1.Text = credit
If credit < 110 Then RichTextBox1.Text = "You do not have enough credit to purchase Pepsi Max"
End Sub
Private Sub Button12_Click(sender As System.Object, e As System.EventArgs) Handles Button12.Click
RichTextBox1.Text = "You Have Selected Mountain Dew, Please Insert 99p"
If credit >= 99 Then RichTextBox1.Text = "Thank you for purchasing Mountain Dew"
credit = credit - 99
TextBox1.Text = credit
If credit < 99 Then RichTextBox1.Text = "You do not have enough credit to purchase Mountain Dew"
End Sub
Private Sub Button10_Click(sender As System.Object, e As System.EventArgs) Handles Button10.Click
RichTextBox1.Text = "You Have Selected Fanta, Please Insert £1.05"
If credit >= 105 Then RichTextBox1.Text = "Thank you for purchasing Fanta"
credit = credit - 105
TextBox1.Text = credit
If credit < 105 Then RichTextBox1.Text = "You do not have enough credit to purchase Fanta"
End Sub
Private Sub Button11_Click(sender As System.Object, e As System.EventArgs) Handles Button11.Click
RichTextBox1.Text = "You Have Selected Dr.Pepper, Please Insert £1.20"
If credit >= 120 Then RichTextBox1.Text = "Thank you for purchasing Dr.Pepper"
credit = credit - 120
TextBox1.Text = credit
If credit < 120 Then RichTextBox1.Text = "You do not have enough credit to purchase Dr.Pepper"
End Sub
Private Sub Button13_Click(sender As System.Object, e As System.EventArgs) Handles Button13.Click
RichTextBox1.Text = "You Have Selected Buxton Mineral Water, Please Insert 90p"
If credit >= 90 Then RichTextBox1.Text = "Thank you for purchasing Buxton Mineral Water"
credit = credit - 90
TextBox1.Text = credit
If credit < 90 Then RichTextBox1.Text = "You do not have enough credit to purchase Buxton Mineral Water"
End Sub
Private Sub Button14_Click(sender As System.Object, e As System.EventArgs) Handles Button14.Click
credit = credit + 1
TextBox1.Text = credit
End Sub
Private Sub Button21_Click(sender As System.Object, e As System.EventArgs) Handles Button21.Click
credit = credit + 2
TextBox1.Text = credit
End Sub
Private Sub Button20_Click(sender As System.Object, e As System.EventArgs) Handles Button20.Click
credit = credit + 5
TextBox1.Text = credit
End Sub
Private Sub Button19_Click(sender As System.Object, e As System.EventArgs) Handles Button19.Click
credit = credit + 10
TextBox1.Text = credit
End Sub
Private Sub Button18_Click(sender As System.Object, e As System.EventArgs) Handles Button18.Click
credit = credit + 20
TextBox1.Text = credit
End Sub
Private Sub Button17_Click(sender As System.Object, e As System.EventArgs) Handles Button17.Click
credit = credit + 50
TextBox1.Text = credit
End Sub
Private Sub Button16_Click(sender As System.Object, e As System.EventArgs) Handles Button16.Click
credit = credit + 100
TextBox1.Text = credit
End Sub
Private Sub Button15_Click(sender As System.Object, e As System.EventArgs) Handles Button15.Click
credit = credit + 200
TextBox1.Text = credit
End Sub
Private Sub Button22_Click(sender As System.Object, e As System.EventArgs) Handles Button22.Click
credit = 0
TextBox1.Text = credit
RichTextBox1.Text = "Credit has been returned"
End Sub
Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
If credit < 0 Then credit = 0
TextBox1.Text = credit
If credit >= 1000 Then credit = 1000
TextBox1.Text = credit
If credit = 1000 Then RichTextBox1.Text = "Maximum credit of £10"
End Sub
Private Sub Button23_Click(sender As System.Object, e As System.EventArgs) Handles Button23.Click
RichTextBox1.Text = "You Have Selected Monster Munch, Please Insert 90p"
If credit >= 90 Then RichTextBox1.Text = "Thank you for purchasing Monster Munch Crisps"
credit = credit - 90
TextBox1.Text = credit
If credit < 90 Then RichTextBox1.Text = "You do not have enough credit to purchase Monster Munch Crisps"
End Sub
End Class

How do I make it so it only displays that message if the credit is not
enough to buy the product before-hand and not straight away after the
purchase?
First off, you should always use an End If to close off your If statements, even if they only have one line in them. Not doing so leads to subtle bugs where you think a "block" of code is running when the If statement is true, but only the first line is affected and the rest always run.
For your specific code, you're so close. By adding an Else block, an End If, and reformatting the code, it becomes as simple as:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
RichTextBox1.Text = "You Have Selected Galaxy Caramel, Please Insert 60p"
If credit >= 60 Then
RichTextBox1.Text = "Thank you for purchasing a Galaxy Caramel bar"
credit = credit - 60
TextBox1.Text = credit
Else
RichTextBox1.Text = "You do not have enough credit to purchase a Galaxy Caramel Bar"
End If
End Sub
Obviously you need to change all of the items to follow the pattern above.
Secondly, how would I go about making a system for the credit left
over after the purchase, as at the moment I have only got a credit
return button which the user would use to extract the remaining credit
left over after the purchase, instead of a system for giving out
change.
Not sure what you mean here. Can you explain in more detail what you want to happen?
Finally, how would I make it so the user is not allowed to enter text
into a text-box as the vending machine uses two text box's, one to
display credit and the other to display other general messages such as
to clarify that you have bought a certain product or that you do not
have enough credit to purchase a certain product.
Both the TextBox and the RichTextBox have a ReadOnly() property you can set to True so that they cannot be changed by the user. But since they are using the buttons only, and don't need to type at all, why not use a different control like Labels instead?

You can use a State Machine for this scenario. Head First Design Patterns has a good example of Vending Machine using State Design pattern. Even though the book gives samples in Java, you can still work out the concepts.
For calculating change, I wrote this block below. It takes in available coin inventory and change required and returns a boolean to indicate if all change can be returned. The method will attempt to return the maximum change possible with the given inventory.
/// <summary>
/// This method attempts to calculate required change from a given coin inventory
/// </summary>
/// <param name="coinInventory">Key is the denomination of coin and value is the available number </param>
/// <param name="changeRequired">The change to count and return</param>
/// <param name="updatedCoinInventory"></param>
/// <param name="coinsToReturn"></param>
/// <returns>True if changeRequired could be calculated, False if coinsToReturn represent less than changeRequired </returns>
public bool GetChange(IDictionary<int, int> coinInventory, int changeRequired,
ref IDictionary<int, int> updatedCoinInventory,
ref IDictionary<int, int> coinsToReturn,
ref int amountDue)
{
int changeOutstanding = changeRequired;
updatedCoinInventory = coinInventory.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
coinsToReturn = new Dictionary<int, int>();
foreach (KeyValuePair<int, int> coin in coinInventory)
{
if (changeOutstanding == 0) break;
int numberOfAvailableCoins = coin.Value;
while (changeOutstanding >= coin.Key && numberOfAvailableCoins >= 1)
{
if (!coinsToReturn.ContainsKey(coin.Key))
{
coinsToReturn.Add(coin.Key, 1);
}
else
{
++ coinsToReturn[coin.Key];
}
changeOutstanding = changeOutstanding - coin.Key;
-- updatedCoinInventory[coin.Key];
-- numberOfAvailableCoins;
}
}
amountDue = changeOutstanding;
return changeOutstanding == 0;
}
}
Hope this helps.

Related

is a two-dimensional array to store pay codes and rates only displaying the paycodes then calculate the gross pay by the amount of hours

The application should store the pay codes and rates in a two-dimensional array. It should also display the pay codes from the array in a list box. The btnCalc_Click procedure should display the gross pay, using the number of hours worked and the pay rate corresponding to the selected code.
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Const strPROMPT As String = "Please enter the amount of hours"
Const strTITLE as string = "Hours Amount"
Private strPayGrades(,) As String = {{"A07", "8.50"},
{"A10", "8.75"},
{"B03", "9.25"},
{"B24", "9.90"},
{"C23", "10.50"}}
Dim strHours As String
Dim dblGross As Double
Dim dblHours As Double
Dim dblGradeWage As Double
Dim intR As Integer
Dim intIndex As Integer
Dim strGradeWage As String
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
' fills list box with codes and then selects the first item
For intR = 0 To 4 Step 1
lstCodes.Items.Add(strPayGrades(intR, 0))
Next intR
lstCodes.SelectedIndex = 0
End Sub
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' calculates and displays the gross pay
strHours = InputBox(strPROMPT, strTITLE)
If strHours Like "##" Or strHours Like "#" Then
Double.TryParse(strHours, dblHours)
Integer.TryParse(lstCodes.SelectedIndex.ToString, intIndex)
strGradeWage = strPayGrades(intR + intIndex, 1)
Double.TryParse(strGradeWage, dblGradeWage)
dblGross = dblHours * dblGradeWage
lblGross.Text = dblGross.ToString("c0")
Else
MessageBox.Show("Invalid format please try again",
"Try Again",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
strHours = InputBox(strPROMPT, strTITLE)
End If
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub lstCodes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstCodes.SelectedIndexChanged
lblGross.Text = String.Empty
End Sub
End Class
change strGradeWage = strPayGrades(0 + intIndex, 1)
strGradeWage = strPayGrades(0 + intIndex, 1)
looks like that was the problem

Visual Basic - use parallel arrays for displaying shipping charges based on input entered by user

I really stink at using arrays. I have this working with a 2 dimensional array but cannot figure out how to get it working with parallel one dimensional arrays. The Display Shipping button's Click even should display a shipping charge based on the number of items entered by the user. I am storing the minimum order amounts and shipping charges in parallel arrays. I cannot get the calculations to work correctly. Any help is appreciated.
Public Class frmMain
'declare parallel arrays
Private strNums() As String = {"1", "11", "51", "101"}
Private intShipping() As Integer = {15, 10, 5, 0}
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub txtordered_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtOrdered.KeyPress
' allows the text box to accept numbers and the Backspace key
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub txtordered_TextChanged(sender As Object, e As EventArgs) Handles txtOrdered.TextChanged
lblShipping.Text = String.Empty
End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
'displays the shipping price based on orders
Dim strSearchForNum As Integer
Dim intSub As Integer
Integer.TryParse(txtOrdered.Text, strSearchForNum)
'search the array for the orders greater than zero
'if less than zero show error message
'otherwise display shipping charge
Do Until intSub >= strNums.Length OrElse
strSearchForNum >= CDbl(strNums(intSub))
intSub += 1
Loop
If strSearchForNum = 0 Then
MessageBox.Show("Please enter a number greater than 0", "Number of Orders")
Else
lblShipping.Text = intShipping(intSub).ToString("C2")
End If
txtOrdered.Focus()
End Sub
End Class

Visual Studio 2010 form creation: fill an array with contents of a combobox

Trying to knock out a project that's hanging my code without re-writing the entire thing. In it, I just need to populate an array with the information already in the Names combobox in order to proceed. As I'm not using .NET, my options are limited.
(The end result)*Add a button named “btnShowBalance” displaying the text “ShowBalance.” Write code in its event handler asking the user to enter a client’s name (InputBox). Search the names array for the name entered. If the name is found, use its location to retrieve the matching balance from the balances array. Display the client’s name and balance if the client exists; otherwise, display a not-found message. ****
Public Class Form1
Dim Balances(7) As Decimal
Dim Names(7) As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cboNames.Items.Add("John One")
cboNames.Items.Add("Jack Two")
cboNames.Items.Add("John Three")
cboNames.Items.Add("Jack Four")
cboNames.Items.Add("John Five")
cboNames.Items.Add("Jack Six")
cboNames.Items.Add("John Seven")
cboNames.Items.Add("Jack Eight")
cboBalances.Items.Add("235.50")
cboBalances.Items.Add("78943.98")
cboBalances.Items.Add("230781.10")
cboBalances.Items.Add("78362.00")
cboBalances.Items.Add("12097.20")
cboBalances.Items.Add("89267.34")
cboBalances.Items.Add("34959.06")
cboBalances.Items.Add("559284.50")
For i = 0 To cboNames.Items.Count - 1
Names(i) = cboNames.Text
Next
For i = 0 To cboBalances.Items.Count - 1
Names(i) = cboBalances.SelectedItem
Next
End Sub
Private Sub btnShowBalance_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowBalance.Click
Dim strResult As String
strResult = InputBox("Enter the name of the customer", "Balance Finder")
For i = 0 To Names.Length - 1
If strResult = Names(i) Then
MessageBox.Show(Names(i).ToString & " " & Balances(i).ToString)
End If
Next
End Sub
End Class

Suggestion for storing selected radiobutton into database

I have create multiple choice system where the user need to choose answer from 4 radiobutton before navigate to next question by clicking next button.
So, the I have problem in storing the selected radiobutton into database. At first I create a table where I create columns to store each answer but it failed. Now, I'm stuck. Please give any suggestion where i can store the answer.
Here I provide the code to load the question
p/s: I know i should ask this on different thread but I also stuck on how to randomize the radiobutton.
Public Property Counter() As Integer
Get
Return IIf(ViewState("counter") Is Nothing, 1, CInt(ViewState("counter")))
End Get
Set(ByVal value As Integer
ViewState("counter") = value
End Set
End Property
Protected Sub Next_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Counter += 1
question()
clean()
End Sub
Sub question()
conn.Open()
Dim cmd As New SqlCommand("Select * From ques Where Id=#Id", conn)
cmd.Parameters.AddWithValue("#Id", Counter)
Dim dr1 As SqlDataReader
dr1 = cmd.ExecuteReader
If dr1.Read() Then
Me.lblquestion.Text = dr1("question")
Me.RadioButton1.Text = dr1("right")
Me.RadioButton2.Text = dr1("wrong")
Me.RadioButton3.Text = dr1("wrong2")
Me.RadioButton4.Text = dr1("wrong3")
Else
conn.Close()
Counter += 1
question()
End If
conn.Close()
End Sub
Sub clean()
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
Next.Enabled = False
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
question()
End Sub
Protected Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Next.Enabled = True
End Sub
Protected Sub RadioButton2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Next.Enabled = True
End Sub
Protected Sub RadioButton3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
Next.Enabled = True
End Sub
Protected Sub RadioButton4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
Next.Enabled = True
End Sub
End Class
I would have a database structure like this:
TblQuizes
Quiz_Id int
Quiz_Name nvarchar(200) -- or any other number that meets your demands
TblQuestions
Question_Id int
Question_Quiz_Id int --(FK To TblQuizes)
Question_Text nvarchar(200) -- or any other number that meets your demands
TblAnswers
Answer_Id int
Answer_Question_Id int --(FK To TblQuestions)
Answer_Text nvarchar(200) -- or any other number that meets your demands
Answer_IsCorrect bit
TblResults
Result_Id int
Result_Quiz_Id int -- (FK to TblQuizes) (not even needed, just to convenience)
-- Add user data in this table if you need it
TblResultDetails
ResultDetails_Id int
ResultDetails_Result_Id int --(FK to TblResults)
ResultDetails_Answer_Id int (FK to TblAnswers)
Now what I would do is create a new record in TblResults for every user that answers the quiz, and store the users answers in TblResultDetails.
On this basic structure you can create views to give you the entire data you need to show the quiz to the user, or to show him how well he answered your questions, and so on. you can also see very easily if a user did not complete the quiz, just by comparing the number of records in TblQuetions and TblResultDetails for a specific quiz id.
Also, if you ever want to have questions with only 2 answer, or 6 answers, you don't have to change anything in the database structure or in your code to have that.

Array will not work in VB.NET

Dim Cans(7) As String
Dim money As Decimal
Public Sub Main()
Cans(0) = "Pepsi"
Cans(1) = "Pepsi MAX"
Cans(2) = "Sprite"
Cans(3) = "Mountain Dew"
Cans(4) = "Fanta"
Cans(5) = "Coca Cola"
Cans(6) = "Coke Diet"
Cans(7) = "Coke Vanilla"
End Sub
Private Sub ButtonPepsi_Click(sender As System.Object, e As System.EventArgs) Handles ButtonPepsi.Click
If money >= 0.8 Then
money = money - 0.8
TextBoxItem.TextAlign = HorizontalAlignment.Center
TextBoxItem.Text = "You brought a " & Cans(0)
TextboxCredit.Text = "£" & money
End If
End Sub
Every time I click the button to buy a pepsi, it just says in the textbox "You bought a " and it should say "Pepsi" but it does not work. Anybody got any ideas?
VB.NET has many methods of starting your application. Which one is used can be set in the project properties. The most common ones are:
Sub Main: Here, a sub Main in a module is called. Then, it's the sub's responsibility to start forms that should be shown.
Start Form: This is probably the option you are using. A specific form is opened and shown to the user. No Sub Main is executed.
How do you solve your problem? If you want to initialize the array when the window is opened, just use the Form.Load event for that:
Public Sub Form_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Cans(0) = "Pepsi"
Cans(1) = "Pepsi MAX"
...
End Sub
Main is never called, that's why your array elements are all empty string. I think you are mixing console and windows applications. You can place a call to Main in Sub New, after InitializeComponent. Or better, move all that code after InitializeComponent, to avoid confusion.
Or just declare your Cans array like this:
Dim Cans() As String = {"Pepsi", ..., "Coke Vanilla"}
Then you don't need Main at all.
Try this,
Private Sub ButtonPepsi_Click(sender As System.Object, e As System.EventArgs) Handles ButtonPepsi.Click
Main()
If money >= 0.8 Then
money = money - 0.8
TextBoxItem.TextAlign = HorizontalAlignment.Center
TextBoxItem.Text = "You brought a " & Cans(0)
TextboxCredit.Text = "£" & money
End If
End Sub

Resources