Text Box Question

can anybody tell me how to format that value while typing (change event) into the textbox?

1,234,456,657.98

thanks
blacklordAsked:
Who is Participating?
 
gecko_au2003Connect With a Mentor Commented:
if you go to the change event of the text box, type :

format(textbox1.text, ###,###,###.00)

basically you tell it to use the format function and in the parentsis you put the value you want formatting which in your case is what ever is entered into the textbox so I put textbox1.text and then after the comma you put the format you want the value obviously.

or something like that,  here is a pdf file that should help you out :

http://webspace.dialnet.com/paul_pbcoms/vb/vb6.pdf

I hope this helps, kind regards

shane

0
 
Mikal613Commented:
you may want to use the MaskedEdit Control
0
 
blacklordAuthor Commented:
I cant because the number lenght is not always the same. I think that I should use textbox.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Mikal613Commented:
it doesnt make a differnce the Mask takes care of that
0
 
blacklordAuthor Commented:
Ok but How can I format that field while it is typeing? I mean on change event? Because  Maskedbox formats the value on lost foucs event. And If I use mask control I have to give the maximum digit, because user might enter milliions or cents.
0
 
Mikal613Commented:
well you write ###,###,###.00

as the mask and it will format it as you write it.
0
 
Mikal613Commented:
Standard cant talk to the satellite  
0
 
blacklordAuthor Commented:
ok but how can you enter that value into that field? 1,233.66
by typing 000,001,233.66 ?
0
 
Mikal613Commented:
# means that its blank if its not there
0 means that it fills it with a 0 if not used
0
 
blacklordAuthor Commented:
I'm able to enter this value which is the last thing that I want in my db :)
34_,___,_45.00
0
 
Mikal613Commented:
thats not a value

 000,001,233.66  = 1,233.66  is a value
0
 
bramsquadCommented:
   Private Sub txtNum_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNum.TextChanged
        Try
            txtNum.Text = CLng(txtNum.Text).ToString("N0")
            txtNum.SelectionStart = txtNum.TextLength
        Catch ex As Exception
        End Try
    End Sub

~b
0
 
blacklordAuthor Commented:
thanks for answer bramsquad but I am using vb6.0
0
All Courses

From novice to tech pro — start learning today.