What's new

Visual Basic [Closed] 50Php Smartload para sa unang makakasolve ng problem na to.

Status
Not open for further replies.

KlayThompson

Eternal Poster
Joined
Dec 1, 2020
Posts
578
Solutions
1
Reaction
298
Points
268
Bibigyan ko po ng 50php worth of Smartload ang makakasolve nitong problem nato. Ito po Visual basic programming activity po gusto ko lang sana malaman kung sana kung saan ako nagkulang.

Ito po yung problem:

1612869178815.png


Ito po yung UI:

1612869250918.png



Ito po yung code ko pero kulang po eh kasi isang beses lang sya nagtototal at ayaw ma-add sa next input ng user. (Check nyo nalang po yung problem sa taas para sa impormasyon).

Code:
Option Explicit On
Option Strict On
Option Infer Off

Public Class Form1
    Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click

        Const Tax As Decimal = 0.05D
        Dim Shipping As Decimal = 6.5D
        Dim decSubtotal As Decimal
        Dim decSalesTax As Decimal
        Dim decTotal As Decimal
        Dim decItemPrice As Decimal
        Dim intCount As Integer

        Decimal.TryParse(txtItemPrice.Text, decItemPrice)


        decSubtotal = decItemPrice
        decSalesTax = decItemPrice * Tax
            decTotal = decSubtotal + decSalesTax + Shipping

            If (decSubtotal >= 100) Then
                decTotal = decTotal - Shipping
                Shipping = 0.0D
            End If

            lblSubtotal.Text = decSubtotal.ToString("c2")
            lblSalesTax.Text = decSalesTax.ToString("c2")
            lblShipping.Text = Shipping.ToString("c2")
        lblTotal.Text = decTotal.ToString("c2")


    End Sub

    Private Sub txtItemPrice_Click(sender As Object, e As EventArgs) Handles txtItemPrice.Click

        txtItemPrice.SelectAll()
    End Sub

    Private Sub txtItemPrice_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtItemPrice.KeyPress

        If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then
            e.Handled = True
        End If
    End Sub

    Private Sub txtItemPrice_TextChanged(sender As Object, e As EventArgs) Handles txtItemPrice.TextChanged

        lblSubtotal.Text = String.Empty
        lblSalesTax.Text = String.Empty
        lblShipping.Text = String.Empty
        lblTotal.Text = String.Empty
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class

Unang makakasolve po bibigyan ko ng 50php Smartload po. Salamat po!
 

Attachments

dee-u lods yung unang input ni user tapos yung result nun ma-aadd sa susunod na iinput na item price. ito dapat output lods.
if the user enters 15.75 as the price and then clicks the Calculate button, the button’s Click event procedure should display 15.75 as the subtotal, 0.79 as the sales tax, 6.50 as the shipping charge, and 23.04 as the total due. If the user subsequently enters 10 as the price and then clicks the Calculate button, the button’s Click event procedure should display 25.75 as the subtotal, 1.29 as the sales tax, 6.50 as the shipping charge, and 33.54 as the total due.
 
Dapat nagkaclue ka na na dapat class-based ang scope ng variable mo. At dapat yung sales tax ay sa subtotal magcompute.
[CODE lang="csharp" title="Code" highlight="8,23"]Option Explicit On
Option Strict On
Option Infer Off

Public Class Form1

Dim decItemPrice As Decimal
Dim decSubtotal As Decimal

Private Sub btnCalc_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCalc.Click

Const Tax As Decimal = 0.05D
Dim Shipping As Decimal = 6.5D

Dim decSalesTax As Decimal
Dim decTotal As Decimal
Dim intCount As Integer

Decimal.TryParse(txtItemPrice.Text, decItemPrice)


decSubtotal = decSubtotal + decItemPrice
decSalesTax = decSubtotal * Tax
decTotal = decSubtotal + decSalesTax + Shipping

If (decSubtotal >= 100) Then
decTotal = decTotal - Shipping
Shipping = 0D
End If

lblSubtotal.Text = decSubtotal.ToString("c2")
lblSalesTax.Text = decSalesTax.ToString("c2")
lblShipping.Text = Shipping.ToString("c2")
lblTotal.Text = decTotal.ToString("c2")


End Sub

Private Sub txtItemPrice_Click(ByVal sender As Object, ByVal e As EventArgs) Handles txtItemPrice.Click

txtItemPrice.SelectAll()
End Sub

Private Sub txtItemPrice_KeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles txtItemPrice.KeyPress

If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then
e.Handled = True
End If
End Sub

Private Sub txtItemPrice_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtItemPrice.TextChanged

lblSubtotal.Text = String.Empty
lblSalesTax.Text = String.Empty
lblShipping.Text = String.Empty
lblTotal.Text = String.Empty
End Sub

'Private Sub btnExit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnExit.Click
' Me.Close()
'End Sub
End Class[/CODE]
 
Status
Not open for further replies.
Back
Top