I have a textbox formatted to currency with two dec. places. How to use selLenght to select whole field? Me.textbox.selLength=12(width of the field in the table) is highlighting only decimal places.
I did a little testing on this. If the data is in the table is "12" and it is displaying "$12.00" then length of me.textbox returns 2 not 6. So I tried
With txtPrice
.SelStart = 0
.SelLength = Len(txtPrice) + 4
End With
but that only worked if I had integer data in the table
did not work if I had data like, 123.456, or 123.4
So I tried this which seems to work, but there has to be a much easier solution.
With txtPrice
.SelStart = 0
.SelLength = Len(Left(txtPrice.Text, InStr(txtPrice.Text, "."))) + 2
End With
It is not working, still highlighting only decimal places. This field is normally locked, with doubleclick I want to unlock it and highlite whole text. Unlocking is working, highliting not.
Too weird - all three work fine for me. Works when the control gets focus (tab into it), not on the click event.
Maybe the code needs to be moved to another event? Clicking in the text box will place the cursor, which could be messing the length? All out of suggestions here so far, but I'll keep an eye on the thread.
Good luck!
Before you criticize someone, you should walk a mile in their shoes.
That way, when you criticize them, you're a mile away and you have their shoes.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.