Format As TIME In A TextBox

M

Minitman

Greetings,

I have a TextBox which is loaded with a date when a UserForm is
opened. I can't get the TextBox to display the entry in a TIME format
(hh:mm AM/PM).

Any help would be appreciated.

TIA

-Minitman
 
M

Minitman

Hey Harold,

Thanks for the reply. This works for current time entries. However,
I am entering times figures other then current time.

Is there a variant that will allow any time to be entered?

-Minitman
 
H

Harald Staff

I thought you had a display problem, sorry. To turn text into a time
variable, use Timevalue:

Dim T As Date
On Error Resume Next
T = TimeValue(TextBox1.Text)
If Err.Number = 0 Then
MsgBox Format$(T, "hh:mm:ss")
Else
MsgBox "No time for losers"
End If

HTH. Best wishes Harald
 
M

Minitman

Hey Harald,

It is a display problem. The first example:

TextBox1.Text = Format$(Now, "hh:mm AM/PM")

Modified like this (The named range on the worksheet is "CallTime"):

TextBox1.Text = Format$(Range("CallTime").Text, "hh:mm AM/PM")

That is what I was trying to remember.

Thanks.

-Minitman
 

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