循环VB.NET中的用户输入文本框



我试图在vb.net中循环这些文本框以接受多个订单。我在循环这些用户输入文本框时遇到麻烦。我希望客户能够订购另一个只有一个客户信息,并将其翻译成文本框TxtOrderDetails ..知道怎么处理这个代码吗?我应该用什么循环。我已经尝试过列表框,但它不会自动计算应付金额,这是我想要的。我希望每笔订单都能自动添加另一笔订单的应付金额……

Private Sub BtnAddOrder_Click(sender As Object, e As EventArgs) Handles BtnAddOrder.Click
'used to restrict empty inputs
If TxtCustomername.Text = "" Or TxtPhone.Text = "" Or TxtPhone.Text = "Invalid! Phone Number" Or TxtDiscount.Text = "" Or TxtDeliveryFee.Text = "" Or CboDrink.Text = "" Or CboQuantity.Text = "" Or TxtSizeprice.Text = "" Then
MessageBox.Show("Please Enter Required Fields!", "Authentication Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Try
'if there are no unwanted inputs then the program proceeds to try other wise if there is an error
'the catch will handle it
Dim AddOns As String
Dim BlackPearl As String
Dim Oreo As String
Dim Nata As String
Dim CoffeeJelly As String
Dim CreamCheese As String
AddOns = " "
BlackPearl = " "
Oreo = " "
Nata = " "
CoffeeJelly = " "
CreamCheese = " "
'declaring the equivalent value of the add ons check boxes
If ChkBoxBlackPearl.Checked = True Then
AddOns = "Black Pearl"
End If
If ChkBoxOreo.Checked = True Then
AddOns = AddOns & "," & " Oreo"
End If
If ChkBoxNata.Checked = True Then
AddOns = AddOns & "," & " Nata De Coco"
End If
If ChkBoxCoffeeJelly.Checked = True Then
AddOns = AddOns & "," & " Coffee Jelly"
End If
If ChkboxCreamCheese.Checked = True Then
AddOns = AddOns & "," & " CreamCheese"
End If
'declaring the values of the payment radio buttons
Dim Payment As String
Payment = " "
If RbtnGcash.Checked = True Then
Payment = "Gcash"
End If
If RbtnDebit.Checked = True Then
Payment = "Debit Card"
End If
If RbtnCoins.Checked = True Then
Payment = "Coins.ph"
End If
'declaring the values of the discount radio buttons
If RbtnCash.Checked = True Then
Payment = "Cash"
End If
Dim DiscountRate As Double
If RbtnPWD.Checked = True Then
DiscountRate = 0.05
End If
If RbtnSenior.Checked = True Then
DiscountRate = 0.1
End If
If RbtnStudent.Checked = True Then
DiscountRate = 0.03
End If
If RbtnDiscountNone.Checked = True Then
DiscountRate = 0
End If
'declaring the values of the transaction radio buttons
Dim Transaction As String
Transaction = " "
If RbtnDelivery.Checked = True Then
Transaction = "15"
End If
If RbtnWalkin.Checked = True Then
Transaction = "None"
End If
'passing the values and converting them to numeric using val to show the total price of the add ons
TxtTotalAddOn.Text = Val(TxtBlackPearl.Text) + Val(TxtOreo.Text) + Val(TxtNataDeCoco.Text) + Val(TxtCoffeeJelly.Text) + Val(TxtCreamCheese.Text)
'declaring values to be computed for the total, cash and change of the customer
Dim TotalPreDelivery As Double
Dim FinalTotal As Double
Dim DiscountPrice As Double
Dim AmountPayable As Double


TotalPreDelivery = Val(TxtTotalAddOn.Text) + Val(TxtSizeprice.Text)
DiscountPrice = TotalPreDelivery * DiscountRate
FinalTotal = TotalPreDelivery - DiscountPrice
AmountPayable = (FinalTotal * Val(CboQuantity.Text)) + Val(TxtDeliveryFee.Text)
'condition to show result it via messagebox
If AddOns.Length <> 0 Then
MessageBox.Show("Choosen DRINK: " + CboDrink.Text + vbCr + "Quantity: " + CboQuantity.Text + vbCr + "Size: " + Sizename + vbCr + "Price " + TxtSizeprice.Text + vbCr + "AddOns: " + AddOns + vbCr + "Total AddOns " + TxtTotalAddOn.Text + vbCr + "Delivery Fee" + TxtDeliveryFee.Text + vbCr + "Discount " + TxtDiscount.Text)
End If
'process to show the results via textbox 
TxtOrderDetails.Text = ("Customer Name: " + TxtCustomername.Text + vbCrLf + "Phone Number: " + TxtPhone.Text + vbCrLf + "Address: " + TxtAddress.Text + vbCrLf + "***********************************************************" + vbCrLf + "Choosen DRINK: " + CboDrink.Text + vbCrLf + "Quantity: " + CboQuantity.Text + vbCrLf + "Size: " + Sizename + vbCrLf + "Price: Php  " + TxtSizeprice.Text + vbCrLf + "AddOns: " + vbCrLf + AddOns + vbCrLf + "Total Price of AddOns:  Php " + TxtTotalAddOn.Text + vbCrLf + "Delivery Fee:  Php  " + TxtDeliveryFee.Text + vbCrLf + "Mode Of Payment:  " + Payment + vbCrLf + "Total Price For Each MilkTea: Php  " + FinalTotal.ToString + vbCrLf + "Discount Rate:  " + TxtDiscount.Text + vbCrLf + "***********************************************************" + vbCrLf + "              Thank You For Your Order" + vbCrLf + "***********************************************************" + vbCrLf + "Date Of Transaction: " + DateTimePicker1.Text)

TxtAmountPayable.Text = ("Php " + AmountPayable.ToString)

使用textbox.clear()清除需要重复输入的文本框,如产品信息。设置全局变量记录AmountPayable,然后将新价格添加到AmountPayable每个按钮事件。