06-22-2011, 08:22 AM
Well a friend asked me if I could finish a small program we're supposed to create, using VB 2010.
It's supposed to be a program that calculates costs, along with how much change you'll get, and how much the total is, etc. Like a till.
So I started off and got this error:
Conversion from string "" to type 'Integer' is not valid. [COST1]
Anybody know what I have done wrong here?
It's supposed to be a program that calculates costs, along with how much change you'll get, and how much the total is, etc. Like a till.
So I started off and got this error:
Spoiler (Click to View)
Code:
Public Class Form1
Dim item1 As String
Dim cost1 As Integer
Dim item2 As String
Dim cost2 As Integer
Dim item3 As String
Dim cost3 As Integer
Dim item4 As String
Dim cost4 As Integer
Dim totalcost As Integer
Dim tendered As Integer
Dim change As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
item1 = InputBox("Please enter the item name")
cost1 = InputBox("Please enter the cost of the item")
item2 = InputBox("Please enter the item name")
cost2 = InputBox("Please enter the cost of the item")
item3 = InputBox("Please enter the item name")
cost3 = InputBox("Please enter the cost of the item")
item4 = InputBox("Please enter the item name")
cost4 = InputBox("Please enter the cost of the item")
tendered = InputBox(" How much has the customer given?")
totalcost = cost1 + cost2 + cost3 + cost4
change = tendered - totalcost
Me.Show()
Conversion from string "" to type 'Integer' is not valid. [COST1]
Anybody know what I have done wrong here?