ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   forms / text boxes (https://www.excelbanter.com/excel-programming/351230-forms-text-boxes.html)

JT

forms / text boxes
 
I have 2 questions:

First, is there a way to format a text box for dates. One of the text boxes
on my form is for the user to enter a date. I would like to format the text
box so all the user has to do is enter mmddyy and the field is automatically
populated as mm/dd/yy.

Second, is there a way select the entire field in a form. Once the user
clicks enter on the form, a number of edits are performed. If there is an
issue with the field, I would like to move the cursor back to the field in
question (setfocus - no problem) but then I would like to select whatever is
in the text box, so the user can just key over the existing info.

Thanks for the help........
--
JT

Tom Ogilvy

forms / text boxes
 
There is no formatting a textbox. You would have to use the change event or
one of the key events to handle the formatting.

use the selstart and sellength properties of the textbox

TextBox1.SelStart = 1
TextBox1.SelLength = len(textbox1.Text)

--
Regards,
Tom Ogilvy


"JT" wrote in message
...
I have 2 questions:

First, is there a way to format a text box for dates. One of the text

boxes
on my form is for the user to enter a date. I would like to format the

text
box so all the user has to do is enter mmddyy and the field is

automatically
populated as mm/dd/yy.

Second, is there a way select the entire field in a form. Once the user
clicks enter on the form, a number of edits are performed. If there is an
issue with the field, I would like to move the cursor back to the field in
question (setfocus - no problem) but then I would like to select whatever

is
in the text box, so the user can just key over the existing info.

Thanks for the help........
--
JT





All times are GMT +1. The time now is 02:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com