-1
我需要計算另一種形式的ListBox
中所有值的折扣金額,然後在折扣表單和主窗體中打印該值。以另一種形式更改標籤的值
折扣形式代碼:
Private Sub btnCalculateVisit_Click(sender As Object, e As EventArgs) Handles btnCalculateVisit.Click
Dim dblVisits As Double = 0
If (IsNumeric(txtVisits.Text)) Then
If txtVisits.Text >= 0 And txtVisits.Text <= 3 Then
dblVisits = (dblVisitRates(0) * GlobalVariables.price)
ElseIf txtVisits.Text >= 4 And txtVisits.Text <= 8 Then
dblVisits = (dblVisitRates(1) * GlobalVariables.price)
ElseIf txtVisits.Text >= 9 And txtVisits.Text <= 13 Then
dblVisits = (dblVisitRates(2) * GlobalVariables.price)
ElseIf txtVisits.Text >= 14 And txtVisits.Text <= 1000000 Then
dblVisits = (dblVisitRates(3) * GlobalVariables.price)
End If
End If
lblDiscountAmount.Text = "$" + dblVisits.ToString
End Sub
Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
Dim main As New MainForm()
main.lblDisRate.Text = GlobalVariables.dblType.ToString
Me.Close()
End Sub
計算打印出的優惠形式,但不會改變在主窗體的標籤。我該怎麼做呢?
在「主窗體」上創建一個方法來接受信息,傳遞數據。 – Plutonix
'btnClose_Click'中的代碼不會更新主窗體中的標籤。它正在創建主窗體的新副本(從未顯示),更新該副本中的標籤,然後允許它關閉。 – Blackwood
我將更新代碼添加到btnClose_Click子文件,它仍然沒有顯示任何內容.. main.lblDisRate.Text = GlobalVariables.disRate.ToString main.lblDisRate.Update() –