Hi Good People,
When my form loads it will load with textboxes filled currency
example:...
Textbox1 = TxtSubTotal =£100.00
Textbox2 = TxtVAT =£ 20.00
Textbox3 = TxtWaitingTime =£ 0.00
Textbox4 = TxtTolls =£ 0.00
Textbox5 = TxtGross =£120.00
Textbox1, Textbox2, Textbox5 are completed automatically, How do I update the Txtbox5 (TxtGross) when I insert figures into Textbox3 (TxtWaitingTime) and or Textbox4 (TxtTolls). At the moment I have tried many different coding's, But cannot get the right answer required
Sub SetTB()
Dim tot As Decimal = 0D
For Each c As Control In GroupBox1.Controls
If c.GetType = GetType(TextBox) Then
tot += GetDec(c.Text)
End If
Next
'TxtGross.Text = tot.ToString("£0.00")
'' Waiting Time
'TxtGross.Text = (GetDec(TxtGross.Text) + GetDec(TxtWaitingTime.Text).ToString("£0.00"))
'' VAT charged
'TxtTolls.Text = (GetDec(TxtTolls.Text) + GetDec(TxtGross.Text)).ToString("£0.00")
'' Gross + WaitingTime + Tolls
TxtGross.Text = (GetDec(TxtWaitingTime.Text) + GetDec(TxtTolls.Text) + tot).ToString("£0.00")
End Sub
Private Sub TxtWaitingTime_TextChanged(sender As Object, e As EventArgs) Handles TxtWaitingTime.TextChanged, TxtTolls.TextChanged
Dim tb As TextBox = DirectCast(sender, TextBox)
If Not tb.Name = "TxtWaitingTime" AndAlso Not tb.Name = "TxtTolls" AndAlso Not tb.Text.StartsWith("£") Then
tb.Text = "£" & tb.Text
tb.SelectionLength = 0
tb.SelectionStart = tb.Text.Length
End If
SetTB()
End Sub
Another sample of my code...
Private Sub TxtWaitingTime_TextChanged(sender As Object, e As EventArgs) Handles TxtWaitingTime.TextChanged
Dim sum1 As Decimal = GetDec(TxtGross.Text)
Dim sum2 As Decimal = GetDec(TxtWaitingTime.Text)
TxtGross.Text = sum2 + sum1
TxtGross.Text = FormatCurrency(TxtGross.Text)
SetTB()
End Sub
Private Sub TxtTolls_TextChanged(sender As Object, e As EventArgs) Handles TxtTolls.TextChanged
Dim sum1 As Decimal = GetDec(TxtGross.Text)
Dim sum2 As Decimal = GetDec(TxtTolls.Text)
TxtGross.Text = sum1 + sum2
TxtGross.Text = FormatCurrency(TxtGross.Text)
SetTB()
End Sub
Can any of you good people Please help me
Kind Regards
Gary