ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Quick Q about time in VBA (https://www.excelbanter.com/excel-programming/277036-quick-q-about-time-vba.html)

neil

Quick Q about time in VBA
 
I have a form, when the user presses a button it writes
the time into a textbox, I then write the data in the
textbox to a datatable. The for activate event loads up
the data from the data table, when the value comes back
in its as a fraction, how do i convert the fraction to a
valid time ? I have looked in the help but couldnt pin it
down :(

papou[_7_]

Quick Q about time in VBA
 
Hi Tom
Ok noted, but can you explain why?
Is this also true with defined names?
eg: [MyName].ClearContents
Thanks
Regards
Pascal

"Tom Ogilvy" a écrit dans le message de
...
If you are happy with the way it looks on the sheet:

Me.TextBox1.Value = Sheets("Feuil3").Range("A3").Text

would be an option as well.


Note that using [A3] vice Range("A3") is three times slower.
--
Regards,
Tom Ogilvy


"papou" <nspm wrote in message
...
Hello Neil
Use Format to convert into a time format
ie:
Me.TextBox1.Value = Format(Sheets("Feuil3").[A3], "HH:MM")
HTH
Regards
Pascal

"Neil" a écrit dans le message de
...
I have a form, when the user presses a button it writes
the time into a textbox, I then write the data in the
textbox to a datatable. The for activate event loads up
the data from the data table, when the value comes back
in its as a fraction, how do i convert the fraction to a
valid time ? I have looked in the help but couldnt pin it
down :(








Tom Ogilvy

Quick Q about time in VBA
 
[ ] is equivalent to evaluate. You are asking Excel to evaluate the
expression in the brackets. This is slower than just having VBA use the
object reference. I would assume the same would be true for defined names,
although I haven't tested it. I did test the range reference.

--
Regards,
Tom Ogilvy


"papou" <nspm wrote in message ...
Hi Tom
Ok noted, but can you explain why?
Is this also true with defined names?
eg: [MyName].ClearContents
Thanks
Regards
Pascal

"Tom Ogilvy" a écrit dans le message de
...
If you are happy with the way it looks on the sheet:

Me.TextBox1.Value = Sheets("Feuil3").Range("A3").Text

would be an option as well.


Note that using [A3] vice Range("A3") is three times slower.
--
Regards,
Tom Ogilvy


"papou" <nspm wrote in message
...
Hello Neil
Use Format to convert into a time format
ie:
Me.TextBox1.Value = Format(Sheets("Feuil3").[A3], "HH:MM")
HTH
Regards
Pascal

"Neil" a écrit dans le message de
...
I have a form, when the user presses a button it writes
the time into a textbox, I then write the data in the
textbox to a datatable. The for activate event loads up
the data from the data table, when the value comes back
in its as a fraction, how do i convert the fraction to a
valid time ? I have looked in the help but couldnt pin it
down :(










All times are GMT +1. The time now is 08:48 AM.

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