Quick Q about time in VBA

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

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 :(
 
Hi Tom
Ok noted, but can you explain why?
Is this also true with defined names?
eg: [MyName].ClearContents
Thanks
Regards
Pascal

Tom Ogilvy said:
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 said:
Hello Neil
Use Format to convert into a time format
ie:
Me.TextBox1.Value = Format(Sheets("Feuil3").[A3], "HH:MM")
HTH
Regards
Pascal

Neil said:
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 :(
 
[ ] 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 said:
Hi Tom
Ok noted, but can you explain why?
Is this also true with defined names?
eg: [MyName].ClearContents
Thanks
Regards
Pascal

Tom Ogilvy said:
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 said:
Hello Neil
Use Format to convert into a time format
ie:
Me.TextBox1.Value = Format(Sheets("Feuil3").[A3], "HH:MM")
HTH
Regards
Pascal

"Neil" <[email protected]> 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 :(
 
Back
Top