拜託 VB程式高手解答 (拜託提供程式碼) 獻上20點

1.設計計算購物運費. 基本物流處理費299 1~5公斤,每公斤30元

,超過5公斤,每ㄧ斤為20元,在文字方塊輸入購物重量 ,計算

和顯示購物所需的運費+物流處理費?

2.計算車資,在文字方塊輸入里程數後,就可計算車資,里程數

再1500公尺內是80元,每多跑500公尺加50元,如果不足500公尺

乙500公尺計算

拜託高手提供程式碼 (版本VB2005)

解決獻上 點數(20點)

1 Answer

Rating
  • MrAYD
    Lv 5
    1 decade ago
    Favorite Answer

    Public Class Form1

    Dim i, sum, n, j, x As Integer

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    End

    End Sub

    Sub com1(ByVal n As Integer)

    i = 299

    sum = 0

    x = n

    For j = 1 To n

    If (x >= 1 And x <= 5) Then

    sum = sum + 30

    Else

    sum = sum + 20

    End If

    x = x - 1

    Next

    Label3.Text = i + sum

    End Sub

    Sub com2(ByVal n As Integer)

    sum = 0

    x = n

    For j = 1500 To n Step 500

    If (x >= 1 And x <= 1500) Then

    sum = sum + 80

    Else

    sum = sum + 50

    End If

    x = x - 500

    Next

    Label3.Text = sum

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim a As Integer

    n = TextBox1.Text

    a = TextBox2.Text

    If (a Mod 2 = 1) Then

    Call com1(n)

    Else

    Call com2(n)

    End If

    End Sub

    End Class

    Source(s): ME
Still have questions? Get your answers by asking now.