Converting Text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have a user form where I enter the date in a text box in the format of m-d (month-day[3-7]). How do I insert this into a cell and have it automatically convert over into m/d/yyyy
Also, I enter the time in another text box as h:m. How do I insert it into a cell and convert it to 24 hour time
And last but not least, I enter a number in a textbox. How do I convert it over into a numeric value
The cells are already formated the way I want, I'm just trying to build and use a form. Thanks.
 
Hi Clayton

Look at the Format function
See the help for more information

Private Sub CommandButton1_Click()
If IsDate(TextBox1) Then
ActiveCell.Value = Format(TextBox1, "m/d/yyyy")
Else
MsgBox "no date"
End If
End Sub




--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)




Clayton L. Wilson said:
Hi,
I have a user form where I enter the date in a text box in the format of m-d (month-day[3-7]). How do I insert this into a
cell and have it automatically convert over into m/d/yyyy?
 
Have you tried linking you textboxes to cells? (controlsource property).

If that doesn't work, then use code for the Exit event

activeCell.NumberFormat = "mm/dd/yyyy"
activecell.Value = "3-7"
? activeCell.Text
03/07/2004


Activecell.NumberFormat = "hh:mm"
ActiveCell.Value = "3:00 PM"
? activeCell.Text
15:00

ActiveCell.Value = cdbl(100.35)

--
Regards,
Tom Ogilvy



Clayton L. Wilson said:
Hi,
I have a user form where I enter the date in a text box in the format of
m-d (month-day[3-7]). How do I insert this into a cell and have it
automatically convert over into m/d/yyyy?
Also, I enter the time in another text box as h:m. How do I insert it into
a cell and convert it to 24 hour time?
And last but not least, I enter a number in a textbox. How do I convert it over into a numeric value.
The cells are already formated the way I want, I'm just trying to build
and use a form. Thanks.
 
Clayton,

Either transfer the value to a cell that is formatted as 'm/d/yyyy', or
format it as you transfer it

Range("A4").Value=format(Text box1.Text,"m/dd/yyyy")

Time is

Range("A5").Value = CDate(TextBox2.Text) * 24

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Clayton L. Wilson said:
Hi,
I have a user form where I enter the date in a text box in the format of
m-d (month-day[3-7]). How do I insert this into a cell and have it
automatically convert over into m/d/yyyy?
Also, I enter the time in another text box as h:m. How do I insert it into
a cell and convert it to 24 hour time?
And last but not least, I enter a number in a textbox. How do I convert it over into a numeric value.
The cells are already formated the way I want, I'm just trying to build
and use a form. Thanks.
 
Back
Top