ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I format a text box control to display the source in time . (https://www.excelbanter.com/excel-programming/322240-how-do-i-format-text-box-control-display-source-time.html)

Patrick

How do I format a text box control to display the source in time .
 
I have a text box control on a form whose control source is a time (e.g.00:00)
Displayed in the text box I get the time as a decimal ((0.375) but want it
displayed as the time.
Can someone tell me how to format the control to do this?
All help appreciated

Juan Pablo González

How do I format a text box control to display the source in time .
 
Use something like

TextBox1.Value = Format$(YourTime, "hh:mm")


--
Regards

Juan Pablo González

"patrick" wrote in message
...
I have a text box control on a form whose control source is a time

(e.g.00:00)
Displayed in the text box I get the time as a decimal ((0.375) but want it
displayed as the time.
Can someone tell me how to format the control to do this?
All help appreciated




sebastienm

How do I format a text box control to display the source in time .
 
Hi Patrick,
Try something like:
TextBox1.Value = Strings.Format(mytime, "hh:mm:ss AM/PM")
where mytime is your time number.

Regards,
Sebastien

"patrick" wrote:

I have a text box control on a form whose control source is a time (e.g.00:00)
Displayed in the text box I get the time as a decimal ((0.375) but want it
displayed as the time.
Can someone tell me how to format the control to do this?
All help appreciated


Bob Phillips[_6_]

How do I format a text box control to display the source in time .
 
Patrick,

If you have linked the textbox to the cell useing ControlSource, you will
need to remove that and load the text box explicitly, like

Textbox1.Text = Worksheets("Sheet1").Range("A1").Text

if the cell is already formatted, or

Textbox1.Text = Fomat(Worksheets("Sheet1").Range("A1").Value,"hh:m m")

if it is not formatted

--

HTH

RP
(remove nothere from the email address if mailing direct)


"patrick" wrote in message
...
I have a text box control on a form whose control source is a time

(e.g.00:00)
Displayed in the text box I get the time as a decimal ((0.375) but want it
displayed as the time.
Can someone tell me how to format the control to do this?
All help appreciated





All times are GMT +1. The time now is 04:26 PM.

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