Text changing

base836ball

Active member
Joined
May 4, 2005
Messages
31
Programming Experience
1-3
I have 3 text boxes, and i coded them to get the value of each text box and in a currency format. What I am trying to do is when I click inside of the first box i want it to stay the currency format, and let me enter the number i want to. Then when i tab out of that box into another i want the number i entered to be seen in the first text box with the currency value. I have tried a lot of different things. I know this cant be hard. any help!!!

Thanks
 
you mean something like this?

VB.NET:
Private decAmount as Decimal

Private Sub Textbox1_GotFocus (...) Handles Textbox1.GotFocus
  'Puts the amount in the box without currency
  Textbox1.Text = decDecimal.ToString
End Sub

Private Sub Textbox1_LostFocus (...) Handles Textbox1.GotFocus
  'If it's a number then format it for currency
  If IsNumeric(Textbox1.Text) = True Then
	decAmount = Convert.ToDecimal(Textbox1.Text)
	Textbox1.Text = FormatCurrency(decAmount)
	'Or:
	'Textbox1.Text = decAmount.ToString("c")
  Else 'Not a number
	MessageBox.Show("Please Enter a number", "Invalid Entry")
  End If
End Sub
 
I figured it out!!!!!!!!!!
__________________________

Private Sub txtHaul_Focus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHaul.LostFocus

dHaul = Val(txtHaul.Text)

txtHaul.Text = Format(dHaul, "Currency")

dTotal = dTotal + dHaul

Totals()

End Sub

Private Sub txtStor_Focus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStor.LostFocus

dStor = Val(txtStor.Text)

txtStor.Text = Format(dStor, "Currency")

dTotal = dTotal + dStor

Totals()

End Sub

Private Sub txtAdd_Focus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAdd.LostFocus

dAdd = Val(txtAdd.Text)

txtAdd.Text = Format(dAdd, "Currency")

dTotal = dTotal + dAdd

Totals()

End Sub

Private Sub txtTAmount_Focus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTAmount.LostFocus

dTAmount = Val(txtTAmount.Text)

txtTAmount.Text = Format(dTAmount, "Currency")

dTotal = dTotal + dTAmount

Totals()

End Sub

'End of 5.1

'---------------------------------------------

Private Sub Totals()

dTotal = dHaul + dStor + dAdd + dTAmount

lblTotal.Text = Format(dTotal, "Currency")

End Sub

 
Back
Top