Vb.net 天知道我已经过了多少次了,有什么问题吗?(售票机)VS上没有错误),我认为最上面的几行可能不起作用

Vb.net 天知道我已经过了多少次了,有什么问题吗?(售票机)VS上没有错误),我认为最上面的几行可能不起作用,vb.net,Vb.net,在过去的几天里,我一直在研究这个问题,就我个人而言,我对VB不感兴趣,这个选项卡正在加载,但我没有得到答案 Private Sub Button1_click(sender As Object, e As EventArgs) Handles Button1.Click Dim Age As Double Dim seatgrading As Double Dim Cardaddition As Single Dim Memberdiscount As S

在过去的几天里,我一直在研究这个问题,就我个人而言,我对VB不感兴趣,这个选项卡正在加载,但我没有得到答案

Private Sub Button1_click(sender As Object, e As EventArgs) Handles Button1.Click 
    Dim Age As Double 
    Dim seatgrading As Double 
    Dim Cardaddition As Single 
    Dim Memberdiscount As Single 
    Dim installments As Double 
    Dim totalcost As Double 
    Dim eachpayment As Integer 
    Dim total As Single 
    Dim price As Single 
    Dim Subtotal As Single 
    Age = CBOAge.Text

    If RBFootball.Checked = True And Age = rbChild.Checked Then
        price = 275
    ElseIf RBFootball.Checked = True And Age = rbAdult.Checked Then
        price = 450
    ElseIf RBFootball.Checked = True And Age = rbOAP.Checked Then
        price = 295
    End If

    If RBRugby.Checked = True And Age = rbChild.Checked Then
        price = 85
    ElseIf RBRugby.Checked = True And Age = rbAdult.Checked Then
        price = 175
    ElseIf RBRugby.Checked = True And Age = rbOAP.Checked Then
        price = 105
    End If

    ' Seat Grades



    If RBG1.Checked = True Then
        seatgrading = 150
    ElseIf RBG2.Checked = True Then
        seatgrading = 120
    ElseIf RBG3.Checked = True Then
        seatgrading = 87.5
    End If
    total = price + seatgrading

    MemberDiscount = installments

    If RBBronze.Checked = True Then
        MemberDiscount = total * 0.08
    ElseIf RBSilver.Checked = True Then
        MemberDiscount = total * 0.09
    ElseIf RBGold.Checked = True Then
        `Cardaddition` = total * 0.025
    End If

    If RBCard.Checked = True Then
        Cardaddition = Subtotal = 0.025
    End If

    If installments = True Then
        installments = total * 0.0375
        total = totalcost + installments
        eachpayment = totalcost / 12
        For count = 1 To 12
            installments = installments & "payment" & "is" & Format(eachpayment, "currency") & vbCrLf
        Next
    End If
    total = Subtotal - MemberDiscount + Cardaddition
    total = Format(totalcost, "currency")

End Sub
这个答案可能更像是向您展示如何获得所需代码的一种方式,而不是一个完整的答案

在处理货币时,最好使用十进制类型,而不是单精度或双精度,否则经过一两次计算后,硬币可能会出错

在另一个
If
语句中可以有一个
If
语句,这有时会减少键入和/或使阅读更容易

我看不出是否需要
age
变量,因为已经有用于儿童/成人/OAP的单选按钮

我不清楚最终总价的计算方法,所以我把一些东西按正确或不正确的顺序排列

也许
分期付款
变量是用于检查是否每月付款的复选框-我假设是这样的

我看不到结果显示给用户的位置,所以我使用了
MessageBox.Show
-我相信您将能够调整它以适应您想要显示总数的方式,等等

Private Sub Button1_click(sender As Object, e As EventArgs) Handles Button1.Click

    ' What I think the variable types are:
    ' Dim rbChild, rbAdult, rbOAP As New RadioButton
    ' Dim rbFootball, rbRugby As New RadioButton
    ' Dim rbG1, rbG2, rbG3 As New RadioButton
    ' Dim rbBronze, rbSilver, rbGold As New RadioButton
    ' Dim cbCard As New CheckBox
    ' Dim cbInstallments As New CheckBox


    Dim price As Decimal

    If rbFootball.Checked Then
        If rbChild.Checked Then
            price = 275
        ElseIf rbAdult.Checked Then
            price = 450
        ElseIf rbOAP.Checked Then
            price = 295
        End If

    End If

    If rbRugby.Checked Then
        If rbChild.Checked Then
            price = 85
        ElseIf rbAdult.Checked Then
            price = 175
        ElseIf rbOAP.Checked Then
            price = 105
        End If

    End If

    Dim seatgrading As Decimal

    If rbG1.Checked Then
        seatgrading = 150
    ElseIf rbG2.Checked Then
        seatgrading = 120
    ElseIf rbG3.Checked Then
        seatgrading = 87.5D
    End If

    Dim subtotal As Decimal = price + seatgrading

    Dim memberDiscount As Decimal

    If rbBronze.Checked Then
        memberDiscount = subtotal * 0.08D
    ElseIf rbSilver.Checked Then
        memberDiscount = subtotal * 0.09D
    ElseIf rbGold.Checked Then
        memberDiscount = subtotal * 0.025D
    End If

    Dim cardSurcharge As Decimal

    If cbCard.Checked Then
        cardSurcharge = subtotal * 0.025D
    End If

    Dim total As Decimal = subtotal - memberDiscount + cardSurcharge

    If cbInstallments.Checked Then
        Dim installmentSurcharge = total * 0.0375D
        total = total + installmentSurcharge
        Dim eachpayment As Decimal = total / 12

        MessageBox.Show("Monthly payment is " & eachpayment.ToString("C"))

    End If

    MessageBox.Show("Total payment is " & total.ToString("C"))

End Sub

这不是C#,请使用正确的标签。无需!请回答您的问题,给它一个有意义的标题,并更好地描述您的问题。对不起,以前没有使用过此网站。我鼓励您开始使用
选项,因为在数值变量中,您指定了组合的文本(可以是非数值的)
Age=CBOAge.Text
然后将其与布尔值进行比较
Age=rbChild.Checked
这对我来说没有多大意义。非常感谢!我会尽力让你知道的。