Excel VBA - Userform textbox formatting

T

thesteelmaker

Hi, i have created a form for an Excel SSheet, with various textboxs an
combo boxs. All work fine in that the data entered/selected ends up i
the cells required.

My problem is that it would like some formatting for the textboxs. Th
first box contains the date:

txtDate.Value = Date

The date appears on the form as d/m/yy, but i would like it to b
dd/mm/yy.

Also when this date is placed in a cell, it is in general format jus
as 1/3/04 and not as 38047, it isn't a true date.

Lastly how can i apply some conditional formatting for the other boxs
i.e

txtWeight

Number to 0 or 1 decimal places.

An error message/retry - cancel button if the number is <50 and >100.

Many Thank
 
H

Harald Staff

txtDate.Value = Date

The date appears on the form as d/m/yy, but i would like it to be
dd/mm/yy.

txtDate.Text = Format$(Date, "dd/mm/yy")

..> Also when this date is placed in a cell, it is in general format just
as 1/3/04 and not as 38047, it isn't a true date.

Sure it is. Just format the cell in date format and see for yourself. The system is
actually 38047 days since new year to 1900; which is 1/3/04.
 

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