![]() |
| ||
| never taught how to show the VAT of a total. I know that u divide by 1.175 here is all my programming the problem bits that do not work is the VAT and SUBTOTAL section in the CmdPrintReceipt and the CmdReturnProduct doesnt work on the form. Any help very much appreciated. email me on kamran_bashir786@hotmail.com Dim Products(1 To 20) As String 'stores products names Dim SoldProducts(1 To 25) As String 'stores sold products Dim SoldCosts(1 To 10) As Currency 'stores costs of sold products Dim Prices(1 To 20) As Currency 'stores product price per kg Dim weight As Single 'weight of product to 0.01 of kg Dim ProductCost As Currency 'cost of sold product Dim TotalCost As Currency 'total cost of products sold to current customer Dim NumberOfSales As Integer 'number of products sold to current customer Dim ProductIndex As Integer 'index into products when changing product name/price Private Sub CboProducts_Click() 'finds and displays price per kg of product selected Dim SearchProduct As String 'selected product Dim Found As Boolean ProductIndex = 1 SearchProduct = CboProducts.Text Found = False Do If Products(ProductIndex) = SearchProduct Then 'if product in array 'is the one we are looking for... Found = True 'display its price per kg LblCurrentPrice.Caption = Format(Prices(ProductIndex), "Currency") Else ProductIndex = ProductIndex + 1 '....but if not move to next one End If Loop Until Found End Sub Private Sub CboProductsSold_Click() CmdReturnProduct.Enabled = True End Sub Private Sub CmdNewCustomer_Click() 'sets up the system to proces new customer LstCurrentSale.Clear CmdSell.Enabled = False CmdReturnProduct.Enabled = False CboProductsSold.Clear NumberOfSales = 0 'number of products sold to current TotalCost = 0 'customer and total spent so far must be 0 LblTotalCost.Caption = Format(TotalCost, "Currency") End Sub Private Sub CmdOK_Click() 'stores changes made to product name and/or price Dim NewProduct As String 'name of new product Dim NewPrice As Currency 'new/changed price per kg If Not IsNumeric(TxtNewPrice) Then 'has user input a number? MsgBox ("You have not entered a valid price") TxtNewPrice.SetFocus Else 'numeric value has been input If TxtNewProduct.Text <> "" Then 'has user input a new product? NewProduct = TxtNewProduct.Text 'if yes then store its name NewPrice = TxtNewPrice.Text 'and price Products(ProductIndex) = NewProduct 'in appropriate Prices(ProductIndex) = NewPrice 'array LblCurrentPrice.Caption = "" LblProducts(ProductIndex).Caption = NewProduct 'replacement product 'name on weighting machine with new name CboProducts.RemoveItem CboProducts.ListIndex 'and display it in CboProducts.AddItem NewProduct 'combo box TxtNewProduct.Text = "" Else 'user does not want a new product, 'only to change price of existing one NewPrice = TxtNewPrice.Text Prices(ProductIndex) = NewPrice 'store changes price LblCurrentPrice.Caption = "" End If End If TxtNewPrice.Text = "" End Sub Private Sub CmdReturn_Click() 'Processes a returned product by removing it from SoldProducts array and 'from CboProductSold, and recalculating total spent so far. Two changes to 'the display of products are also done under certain conditions Dim SearchProduct As String 'product to return Dim Found As Boolean Dim Index As Integer 'index into SoldProducts and SoldCosts array Index = 1 Found = False 'product not found yet If CboProductsSold.Text = "" Then 'has product to return been selected? MsgBox ("Please select the product to return") Else 'product has been selected Do SearchProduct = CboProductsSold.Text 'store product selected If SoldProducts(Index) = SearchProduct Then 'is product in the 'current element of array the selected one? Found = True 'if it is then product found CboProductsSold.RemoveItem CboProductsSold.ListIndex 'so remove 'it from combo box SoldProducts(Index) = "" 'and also from array TotalCost = TotalCost - SoldCosts(Index) 'recalculate how mcuh 'current customer has spent so far Else 'product not yet found in array Index = Index + 1 'so move to next product in array End If Loop Until Found 'stop searching when product found If SearchProduct = LstCurrentSale.List(0) Then 'product to return is 'on display in list box LstCurrentSale.Clear 'so remove it End If If CboProductsSold.ListCount = 0 Then 'if there are no more products 'in the combo box then CmdReturnProduct.Enable = False 'disable Return button End If End If LblTotalCost.Caption = Format(TotalCost, "Currency") End Sub Private Sub CmdPrintReceipt_Click() 'print a receipt for the current customer Dim Index As Integer Dim SubTotal As Integer Dim VATTotal As Integer Dim VAT As Integer VAT = 1.175 Printer.Print "KINGSKANDY"; Tab(40); Format(Date, "Long Date") Printer.Print Printer.Print For Index = 1 To NumberOfSales 'process each produc bought If SoldProducts(Index) <> "" Then 'this element of array wil be 'empty if product has been returned Printer.Print SoldProducts(Index); Tab(40); Format(SoldCosts(Index), "Currency") 'print product if it is in array End If Next Index Printer.Print Printer.Print Printer.Print Tab(22); "SubTotal"; Tab(40): SubTotal = Total / VAT Printer.Print Tab(22); "VAT Total"; Tab(40); VATTotal = Total - SubTotal Printer.Print Tab(22); "Total"; Tab(40); Format(TotalCost, "Currency") Printer.Print Printer.Print Printer.Print "69 Queensmere Shopping Centre" Printer.Print "Slough" Printer.Print "Berkshire" Printer.Print "SL1 2RJ" Printer.Print Printer.Print Printer.Print Tab(15); "Thank you for your custom" Printer.EndDoc 'without this method receipt will not 'print until you close the program End Sub Private Sub CmdSell_Click() 'processes sale of one product - calculate its cost and stores details 'of the sale Dim ProductSold As String 'name of sold product Dim ProductSoldCost As Currency 'cost of sold product TotalCost = TotalCost + ProductCost 'calculate total cost so far LblTotalCost.Caption = Format(TotalCost, "Currency") NumberOfSales = NumberOfSales + 1 'keep count of how many 'products sold so far to customer ProductSold = LstCurrentSale.List(0) 'name of sodl product can 'be taken from first item in list box ProductSoldCost = LstCurrentSale.List(3) 'cost of sold product can 'be taken from first item in list box SoldProducts(NumberOfSales) = ProductSold 'store name of sold product SoldCosts(NumberOfSales) = ProductSoldCost 'store cost of sold product CboProductsSold.AddItem SoldProducts(NumberOfSales) 'add name of 'product to combo box displaying sold products CmdPrintReceipt.Enabled = True End Sub Private Sub Form_Load() 'stores product names and prices and displays product names in the control 'array of labels Dim Index As Integer 'store product names and prices Products(1) = "Truffle - Hazlenut Praline" Prices(1) = 9.02 Products(2) = "Truffle - Cherry Liqueur" Prices(2) = 8.46 Products(3) = "Truffle - White" Prices(3) = 9.02 Products(4) = "Toffee - Nuts" Prices(4) = 8.8 Products(5) = "Toffee - Chocolate" Prices(5) = 5.9 Products(6) = "Fudge - Chocolate" Prices(6) = 10.7 Products(7) = "Turkish Delight - Strawberry" Prices(7) = 9.92 Products(8) = "Toffee - Malted" Prices(8) = 11 Products(9) = "Fudge - Crispy Biscuit" Prices(9) = 10.93 Products(10) = "Turkish Delight - Chocolate" Prices(10) = 6.3 Products(11) = "Fudge - Strawberry" Prices(11) = 7.2 Products(12) = "Turkish Delight - Vanilla" Prices(12) = 8 Products(13) = "Truffle - Caramel" Prices(13) = 7.08 Products(14) = "Biscuits - Chocolate" Prices(14) = 9 Products(15) = "Gift Box - Chocolate" Prices(15) = 6.5 Products(16) = "Gift Box - White" Prices(16) = 9.99 Products(17) = "Gift Box - Caramel" Prices(17) = 7.88 Products(18) = "Biscuits - Caramel " Prices(18) = 10.7 Products(19) = "Mint - Chocolate" Prices(19) = 12.55 Products(20) = "Coffee - Chocolate" Prices(20) = 9.08 For Index = 1 To 20 'display product names in control array of labels LblProducts(Index).Caption = Products(Index) CboProducts.AddItem Products(Index) Next Index TxtWeight.Text = "0.0" 'could have done this at design stage instead End Sub Private Sub LblProducts_Click(Index As Integer) 'calculates cost of product and displays details of sold product in list 'box ProductCost = Prices(Index) * weight 'calculate cost LstCurrentSale.Clear LstCurrentSale.AddItem Products(Index) 'display details LstCurrentSale.AddItem "Price per kg: " & Format(Prices(Index), _ "Currency") LstCurrentSale.AddItem weight & " kg" LstCurrentSale.AddItem Format(ProductCost, "Currency") CmdSell.Enabled = True 'enable Sell Button End Sub Private Sub UpdWeight_Change() 'adds or subtracts 0.1 to the displayed weight weight = UpdWeight.Value / 100 'max property of UpdWeight is 100 so 'divide by 10 to get a weight from 0.0 to 1.0 If weight = 0 Then 'if Weight is 0 then text box displays '0 rather 0.0, so force it to display 0.0 TxtWeight.Text = "0.0" Else TxtWeight.Text = weight End If End Sub[B] xxx[I][B] |
| All times are GMT -4. The time now is 11:35 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC