我不知道为什么这不起作用 [英] I have NO idea why this doesn't work

查看:75
本文介绍了我不知道为什么这不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我不知道为什么这个代码不起作用,我原本试图做一个数字系统,但是搞砸了,所以我恢复了我曾经拥有的代码,但是当我将它转移到这个程序,它只是不会显示收据上的价格
,任何帮助都会很棒这里是我的页面代码 

Help me PLEASE I have no idea why this code isn't working, I was originally trying to do a numericUD system but that messed up so I reverted to having code I used to have which does work, but when I transferred it to this program it just won't show the prices on the reciepts, any help would be great here's my code for the page 

Public Class Form2

    Const Price_Vanilla As Decimal = 1 'Setting the prices
    Const Price_Banana As Decimal = 1.5
    Const Price_Chocolate As Decimal = 1.25
    Const Price_Curry As Decimal = 2.25
    Const Price_LemonCheesecake As Decimal = 1.5
    Const Price_Mint As Decimal = 1.75
    Const Price_Strawberry As Decimal = 1.25
    Const Price_Egg As Decimal = 2.5
    Const Price_Lager As Decimal = 2.25

    Dim Discount As Decimal = -0.1 '10% discount
    Dim total As Decimal
    Dim subtotal As Decimal

    Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        InitialiseVariables()
        ClearTheCustomerSelections()
        ClearTheReciept()
    End Sub

    Private Sub InitialiseVariables() 'to reset all of the values to 0
        subtotal = 0
        total = 0
    End Sub

    Private Sub ClearTheCustomerSelections()
        chkVanilla.Checked = False
        chkChocolate.Checked = False
        chkBanana.Checked = False
        chkMint.Checked = False
        chkLager.Checked = False
        chkLemonCheesecake.Checked = False
        chkStrawberry.Checked = False
        chkCurry.Checked = False
        chkEgg.Checked = False
    End Sub

    Private Sub ClearTheReciept() 'to clear, for the new order button
        lstOrder.Items.Clear()
        lstTotal.Items.Clear()
    End Sub

    Private Sub ComputeCurrentSelection()  ' adding all of the items to the listbox
        If chkVanilla.Checked Then
            subtotal += Price_Vanilla
            Dim VanillaItem As String = _
            Price_Vanilla.ToString("C") & " Vanilla "
            lstOrder.Items.Add(VanillaItem)
        End If
        If chkChocolate.Checked Then
            subtotal += Price_Chocolate
            Dim ChocolateItem As String = _
                Price_Chocolate.ToString("C") & " Chocolate "
            lstOrder.Items.Add(ChocolateItem)
        End If
        If chkBanana.Checked Then
            subtotal += Price_Banana
            Dim BananaItem As String = _
            Price_Banana.ToString("C") & " Banana "
            lstOrder.Items.Add(BananaItem)
        End If
        If chkLemonCheesecake.Checked Then
            subtotal += Price_LemonCheesecake
            Dim LemonCheesecakeItem As String = _
            Price_LemonCheesecake.ToString("C") & " LemonCheesecake "
            lstOrder.Items.Add(LemonCheesecakeItem)
        End If
        If chkMint.Checked Then
            subtotal += Price_Mint
            Dim MintItem As String = _
            Price_Mint.ToString("C") & " Mint "
            lstOrder.Items.Add(MintItem)
        End If
        If chkCurry.Checked Then
            subtotal += Price_Curry
            Dim CurryItem As String = _
            Price_Curry.ToString("C") & " Currye "
            lstOrder.Items.Add(CurryItem)
        End If
        If chkStrawberry.Checked Then
            subtotal += Price_Strawberry
            Dim StrawberryItem As String = _
            Price_Strawberry.ToString("C") & " Strawberry "
            lstOrder.Items.Add(StrawberryItem)
        End If
        If chkEgg.Checked Then
            subtotal += Price_Egg
            Dim EggItem As String = _
            Price_Egg.ToString("C") & " Egg "
            lstOrder.Items.Add(EggItem)
        End If
        If chkLager.Checked Then
            subtotal += Price_Lager
            Dim LagerItem As String = _
            Price_Lager.ToString("C") & " Lager "
            lstOrder.Items.Add(LagerItem)
        End If
        If chkDiscount.Checked Then
            total = total * Discount
        End If
    End Sub

    Private Sub Updatetotal()  'this is to calculate all the items and discount prices
        lstTotal.Items.Clear()
        lstTotal.Items.Add("Sub Total = " & subtotal.ToString("C"))
        total = subtotal
        lstTotal.Items.Add("       total = " & total.ToString("C"))
        total = total * Discount
        lstTotal.Items.Add("       After takeaway = " & total.ToString("C"))
    End Sub

    Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs)  ' this is to calculate the orders
        ComputeCurrentSelection()
        Updatetotal()
        ClearTheCustomerSelections()
    End Sub

    Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click ' this is the code to clear all of the previous input for new order
        InitialiseVariables()
        ClearTheCustomerSelections()
        ClearTheReciept()
    End Sub
End Class




还包括图片但显然我的acc需要先验证


Also would include picture but apparently my acc needs verifying first

推荐答案

Public Class Form1

    Const Price_Vanilla As Decimal = 1 'Setting the prices
    Const Price_Banana As Decimal = 1.5
    Const Price_Chocolate As Decimal = 1.25
    Const Price_Curry As Decimal = 2.25
    Const Price_LemonCheesecake As Decimal = 1.5
    Const Price_Mint As Decimal = 1.75
    Const Price_Strawberry As Decimal = 1.25
    Const Price_Egg As Decimal = 2.5
    Const Price_Lager As Decimal = 2.25

    Dim Discount As Decimal = -0.1 '10% discount
    Dim total As Decimal
    Dim subtotal As Decimal
    Dim subdiscount As Decimal

    Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        InitialiseVariables()
        ClearTheCustomerSelections()
        ClearTheReciept()
    End Sub

    Private Sub InitialiseVariables() 'to reset all of the values to 0
        subtotal = 0
        total = 0
        subdiscount = 0
    End Sub

    Private Sub ClearTheCustomerSelections()
        chkVanilla.Checked = False
        chkChocolate.Checked = False
        chkBanana.Checked = False
        chkMint.Checked = False
        chkLager.Checked = False
        chkLemonCheesecake.Checked = False
        chkStrawberry.Checked = False
        chkCurry.Checked = False
        chkEgg.Checked = False
    End Sub

    Private Sub ClearTheReciept() 'to clear, for the new order button
        lstOrder.Items.Clear()
        lstTotal.Items.Clear()
    End Sub

    Private Sub ComputeCurrentSelection()  ' adding all of the items to the listbox
        If chkVanilla.Checked Then
            subtotal += Price_Vanilla
            Dim VanillaItem As String = Price_Vanilla.ToString("C") & " Vanilla "
            lstOrder.Items.Add(VanillaItem)
        End If
        If chkChocolate.Checked Then
            subtotal += Price_Chocolate
            Dim ChocolateItem As String = Price_Chocolate.ToString("C") & " Chocolate "
            lstOrder.Items.Add(ChocolateItem)
        End If
        If chkBanana.Checked Then
            subtotal += Price_Banana
            Dim BananaItem As String = Price_Banana.ToString("C") & " Banana "
            lstOrder.Items.Add(BananaItem)
        End If
        If chkLemonCheesecake.Checked Then
            subtotal += Price_LemonCheesecake
            Dim LemonCheesecakeItem As String = Price_LemonCheesecake.ToString("C") & " LemonCheesecake "
            lstOrder.Items.Add(LemonCheesecakeItem)
        End If
        If chkMint.Checked Then
            subtotal += Price_Mint
            Dim MintItem As String = Price_Mint.ToString("C") & " Mint "
            lstOrder.Items.Add(MintItem)
        End If
        If chkCurry.Checked Then
            subtotal += Price_Curry
            Dim CurryItem As String = Price_Curry.ToString("C") & " Currye "
            lstOrder.Items.Add(CurryItem)
        End If
        If chkStrawberry.Checked Then
            subtotal += Price_Strawberry
            Dim StrawberryItem As String = Price_Strawberry.ToString("C") & " Strawberry "
            lstOrder.Items.Add(StrawberryItem)
        End If
        If chkEgg.Checked Then
            subtotal += Price_Egg
            Dim EggItem As String = Price_Egg.ToString("C") & " Egg "
            lstOrder.Items.Add(EggItem)
        End If
        If chkLager.Checked Then
            subtotal += Price_Lager
            Dim LagerItem As String = Price_Lager.ToString("C") & " Lager "
            lstOrder.Items.Add(LagerItem)
        End If
        If chkDiscount.Checked Then
            total = subtotal * (1 - Discount)
            subdiscount = subtotal * Discount
        Else
            total = subtotal

        End If
    End Sub

    Private Sub Updatetotal()  'this is to calculate all the items and discount prices
        lstTotal.Items.Clear()
        lstTotal.Items.Add("Sub Total = " & subtotal.ToString("C"))
        'total = subtotal
        lstTotal.Items.Add("       total = " & total.ToString("C"))
        'total = total * Discount
        lstTotal.Items.Add("       After takeaway = " & subdiscount.ToString("C"))
    End Sub

    Private Sub btnCalculate_Click(sender As System.Object, e As System.EventArgs) Handles Calculate.Click  ' this is to calculate the orders
        ComputeCurrentSelection()
        Updatetotal()
        ClearTheCustomerSelections()
    End Sub

    Private Sub btnReset_Click(sender As System.Object, e As System.EventArgs) Handles btnReset.Click ' this is the code to clear all of the previous input for new order
        InitialiseVariables()
        ClearTheCustomerSelections()
        ClearTheReciept()
    End Sub
End Class




希望它对您有所帮助。


Hope it can be helpful to you.

如果您对此问题有其他疑问,请随时与我们联系。

If you have something else about this issue, please feel free to contact us.

致以最诚挚的问候,

Bob


这篇关于我不知道为什么这不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆