vb.net 2003 Formatting ... aghhhhhhhhhhhhhhhhh

G

Guest

i need help, im at my wits end, carnt for the life of me understand whats
wrong

I have written private sub to handle validating of text boxes

Private Sub Handles_Validating(ByVal source As Object, ByVal e As
EventArgs) _
Handles textbox1.validated , ??? .etc

Dim tx As TextBox = DirectCast(source, TextBox)
tx.Text = Format(Microsoft.VisualBasic.Right("000000" + tx.Text, 6),
"0#-##-##")

Why oh why when entering in 123456 do i get 0#-##-## instead of
12-34-56 ??? HELP !!!!!!
 
P

Phill W.

Peter said:
Dim tx As TextBox = DirectCast(source, TextBox)
tx.Text = Format(Microsoft.VisualBasic.Right("000000" + tx.Text, 6),
"0#-##-##")

Why oh why when entering in 123456 do i get 0#-##-## instead of
12-34-56 ??? HELP !!!!!!

"0" and "#" only work when formatting /numbers/ - you're passing it a
/String/. Without going all ".Net-y" on you, try this:

tx.Text = Format(Val(tx.Text), "0#-##-##")

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top