JBTALKS.CC

标题: 求大神教我visual basic [打印本页]

作者: PaPaDoom    时间: 2014-4-20 07:54 PM
标题: 求大神教我visual basic
hi 大家好。。

最近我需要做个assignment 关于 cake price calculator.. 我对coding不是很了解。。有人能教我吗? 感恩 可以的话,我把问题send给你(我自己已经写了一些)可是run不到。。。
作者: jxzx2    时间: 2014-4-20 10:13 PM
run不到就因为你的 code有问题
作者: PaPaDoom    时间: 2014-4-20 11:33 PM
jxzx2 发表于 2014-4-20 10:13 PM
run不到就因为你的 code有问题

我不是很了解那个coding。。你可以教我吗?
作者: RE雨宫    时间: 2014-4-21 10:08 AM
你Run不到是Coding有Error了~
下面有行Error Bar告诉你Error是什么,
可以参考那个然后修复Error哟
作者: SwaiLspongebob    时间: 2014-4-21 10:30 AM
Public Class formQ2
    Private Sub btnOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOrder.Click
        Dim amount As Double
        Dim shape = TotalShape()
        Dim flavour = TotalFlavour()
        Dim topping = TotalTopping()
        Dim delivery = TotalDelivery(amount)
        Dim befDiscount = TotalBeforeDiscount(shape, flavour, topping, delivery)
        Dim aftDiscount = TotalDiscount(befDiscount)

        txtTotal.Text = ("$" & aftDiscount)
    End Sub
    Function TotalShape() As Double
        Dim price As Double = 0
        If rdbRound.Checked Then
            price = 15
            txtShape.Text = "Round"
        Else
            price = 20
            txtShape.Text = "Square"
        End If
        Return price
    End Function
    Function TotalFlavour() As Double
        Dim price As Double = 0
        If chkLemon.Checked Then
            price += 3
            txtFlavour.Text = "Lemon"
        End If
        If chkVanilla.Checked Then
            price += 8
            txtFlavour.Text = "Vanilla"
        End If
        Return price
    End Function
    Function TotalTopping() As Double
        Dim price As Double = 0
        If chkFruits.Checked Then
            price += 6
            txtTopping.Text = "Fruits"
        End If
        If chkCaramel.Checked Then
            price += 10
            txtTopping.Text = "Caramel"
        End If
        Return price
    End Function
    Function TotalDelivery(ByVal amount) As Double
        Dim price As Double = 0
        If chkDelivery.Checked Then
            price += 5
        End If
        Return price
    End Function
    Function TotalBeforeDiscount(ByVal shape, ByVal flavour, ByVal topping, ByVal delivery) As Double
        Dim price As Double = 0
        price = shape + flavour + topping + delivery
        Return price
    End Function
    Function TotalDiscount(ByVal befDiscount) As Double
        Dim price As Double = 0
        If chkDelivery.Checked Then
            If befDiscount >= 30 Then
                price = befDiscount - (befDiscount * 0.2)
            Else
                price = befDiscount
            End If
        Else
            price = befDiscount
        End If
        Return price
    End Function
    Sub ClearAll()
        rdbRound.Checked = False
        rdbSquare.Checked = False
        chkLemon.Checked = False
        chkVanilla.Checked = False
        chkFruits.Checked = False
        chkCaramel.Checked = False
        chkMember.Checked = False
        chkDelivery.Checked = False
        txtName.Clear()
        txtAddress.Clear()
        txtFlavour.Clear()
        txtShape.Clear()
        txtTopping.Clear()
        txtTotal.Clear()
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ClearAll()
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class
作者: paradise168    时间: 2014-4-21 10:43 AM
这个好像是数学问题。coding和界面很简单的。你是做一个界面还是整个系统?
作者: xtjj    时间: 2014-6-5 01:28 AM
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 JBTALKS.CC (https://mobile.jbtalks.cc/) Powered by Discuz! X2.5