Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
C4X C4X is offline
external usenet poster
 
Posts: 3
Default Time formatting issues

I am nearly finished working on my latest project, a data entry GUI in
VBA (2003), and have run into difficulties dealing with time values.

Brief project background: It is a simple data entry form which takes
various bits of flight data and enters them onto a spreadsheet. The
key entries I'm having trouble with are 'Time' values. Two fields are
automatically populated with the appropriate 'Departure' and 'Arrival'
times based on a 'ListIndex' run during initialization, which allows
values for the 'Flight Numbers'. An 'If...Then' statement refers back
to the 'ListIndex':

private sub fltNum_change
......
If fltNum.ListIndex = 3 then 'Flight Number
fltFrom.value="nan" 'Departure airport
fltTo.value="suv" 'Arrival airport
fltATD.value="5:10" 'Departure time
fltATA.value="5:40" 'Arrival time
end if
......
end sub

To allow the user to incrementally change the values, there are spin-
buttons with the following code that formats a time value:

private sub spinbutton3_SpinDown()
fltATD.text=format(timevalue(fltATD.text) - timevalue("00:01"),
"h:mm")
end sub

private sub spinbutton3_SpinUp()
fltATD.text=format(timevalue(fltATD.text) + timevalue("00:01"),
"h:mm")
end sub

This is where I lose the path :(

My next two (and final) goals elude me:
1) Display a value (value 'A') which is '3 minutes' less than the
'departure time' in a textbox with spin-button control, as well as a
value (value 'B') '3 minutes' more than the 'arrival time' in yet
another textbox with spin-button control.

2) Show a value which is value 'B' minus value 'A' in a textbox on the
userform in decimal-time format. I have the 4 values currently output
to a spreadsheet, and am able to easily subtract 'B' from 'A' and show
in a cell formatted with '=(E1-INT(E1))*24'. The correct decimal time
is shown, but I cant manage to show the value on my userform (and
subsequently allow the data to be entered onto the proper
spreadsheet).

Help please! :) If I can sort these two hurdles out, my project is
done.
Thnx
Clarke

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Time formatting issues

I'm a little confused, because you've already supplied most of the answer for goal 1.

In any case, this is probably the code you want.

TextBoxA.Text = Format(TimeValue(fltATD.Text) - TimeValue("00:03"), "h:mm")
TextBoxB.Text = Format(TimeValue(fltATA.Text) + TimeValue("00:03"), "h:mm")
TextBoxC.Text = Format(TimeValue(TextBoxA.Text) - TimeValue(TextBoxB.Text), "h:mm")

I see a problem developing when the departure/arrival times are within 3 minutes of midnight.
You might want to check for these special cases.

Cheers,
Rob


C4X wrote:
I am nearly finished working on my latest project, a data entry GUI in
VBA (2003), and have run into difficulties dealing with time values.

Brief project background: It is a simple data entry form which takes
various bits of flight data and enters them onto a spreadsheet. The
key entries I'm having trouble with are 'Time' values. Two fields are
automatically populated with the appropriate 'Departure' and 'Arrival'
times based on a 'ListIndex' run during initialization, which allows
values for the 'Flight Numbers'. An 'If...Then' statement refers back
to the 'ListIndex':

private sub fltNum_change
.....
If fltNum.ListIndex = 3 then 'Flight Number
fltFrom.value="nan" 'Departure airport
fltTo.value="suv" 'Arrival airport
fltATD.value="5:10" 'Departure time
fltATA.value="5:40" 'Arrival time
end if
.....
end sub

To allow the user to incrementally change the values, there are spin-
buttons with the following code that formats a time value:

private sub spinbutton3_SpinDown()
fltATD.text=format(timevalue(fltATD.text) - timevalue("00:01"),
"h:mm")
end sub

private sub spinbutton3_SpinUp()
fltATD.text=format(timevalue(fltATD.text) + timevalue("00:01"),
"h:mm")
end sub

This is where I lose the path :(

My next two (and final) goals elude me:
1) Display a value (value 'A') which is '3 minutes' less than the
'departure time' in a textbox with spin-button control, as well as a
value (value 'B') '3 minutes' more than the 'arrival time' in yet
another textbox with spin-button control.

2) Show a value which is value 'B' minus value 'A' in a textbox on the
userform in decimal-time format. I have the 4 values currently output
to a spreadsheet, and am able to easily subtract 'B' from 'A' and show
in a cell formatted with '=(E1-INT(E1))*24'. The correct decimal time
is shown, but I cant manage to show the value on my userform (and
subsequently allow the data to be entered onto the proper
spreadsheet).

Help please! :) If I can sort these two hurdles out, my project is
done.
Thnx
Clarke

  #3   Report Post  
Posted to microsoft.public.excel.programming
C4X C4X is offline
external usenet poster
 
Posts: 3
Default Time formatting issues

On Dec 7, 6:39*pm, Rob van Gelder
wrote:
I'm a little confused, because you've already supplied most of the answer for goal 1.

In any case, this is probably the code you want.

* * *TextBoxA.Text = Format(TimeValue(fltATD.Text) - TimeValue("00:03"), "h:mm")
* * *TextBoxB.Text = Format(TimeValue(fltATA.Text) + TimeValue("00:03"), "h:mm")
* * *TextBoxC.Text = Format(TimeValue(TextBoxA.Text) - TimeValue(TextBoxB.Text), "h:mm")

I see a problem developing when the departure/arrival times are within 3 minutes of midnight.
You might want to check for these special cases.

Cheers,
Rob

C4X wrote:
I am nearly finished working on my latest project, a data entry GUI in
VBA (2003), and have run into difficulties dealing with time values.


Brief project background: It is a simple data entry form which takes
various bits of flight data and enters them onto a spreadsheet. The
key entries I'm having trouble with are 'Time' values. Two fields are
automatically populated with the appropriate 'Departure' and 'Arrival'
times based on a 'ListIndex' run during initialization, which allows
values for the 'Flight Numbers'. An 'If...Then' statement refers back
to the 'ListIndex':


private sub fltNum_change
.....
If fltNum.ListIndex = 3 then * * 'Flight Number
* *fltFrom.value="nan" * * * * * * 'Departure airport
* *fltTo.value="suv" * * * * * * * * 'Arrival airport
* *fltATD.value="5:10" * * * * * * 'Departure time
* *fltATA.value="5:40" * * * * * * 'Arrival time
end if
.....
end sub


To allow the user to incrementally change the values, there are spin-
buttons with the following code that formats a time value:


private sub spinbutton3_SpinDown()
* *fltATD.text=format(timevalue(fltATD.text) - timevalue("00:01"),
"h:mm")
end sub


private sub spinbutton3_SpinUp()
* *fltATD.text=format(timevalue(fltATD.text) + timevalue("00:01"),
"h:mm")
end sub


This is where I lose the path :(


My next two (and final) goals elude me:
1) Display a value (value 'A') which is '3 minutes' less than the
'departure time' in a textbox with spin-button control, as well as a
value (value 'B') '3 minutes' more than the 'arrival time' in yet
another textbox with spin-button control.


2) Show a value which is value 'B' minus value 'A' in a textbox on the
userform in decimal-time format. I have the 4 values currently output
to a spreadsheet, and am able to easily subtract 'B' from 'A' and show
in a cell formatted with '=(E1-INT(E1))*24'. The correct decimal time
is shown, but I cant manage to show the value on my userform (and
subsequently allow the data to be entered onto the proper
spreadsheet).


Help please! :) If I can sort these two hurdles out, my project is
done.
Thnx
Clarke


Okay, thnx Rob. I have been staring at this off and on for a while
now. It gets blurry :) Should have worked that out. Anyways, we have
no flights around midnight, should be no prob there. Any thoughts on
how to format the total flight time as a decimal time (i.e: h.mm)? I
haven't come across it and the 'cell formula' I posted above is
unusable it seems . . .thnx.
  #4   Report Post  
Posted to microsoft.public.excel.programming
C4X C4X is offline
external usenet poster
 
Posts: 3
Default Time formatting issues

On Dec 7, 11:09*pm, C4X wrote:
On Dec 7, 6:39*pm, Rob van Gelder
wrote:



I'm a little confused, because you've already supplied most of the answer for goal 1.


In any case, this is probably the code you want.


* * *TextBoxA.Text = Format(TimeValue(fltATD.Text) - TimeValue("00:03"), "h:mm")
* * *TextBoxB.Text = Format(TimeValue(fltATA.Text) + TimeValue("00:03"), "h:mm")
* * *TextBoxC.Text = Format(TimeValue(TextBoxA.Text) - TimeValue(TextBoxB.Text), "h:mm")


I see a problem developing when the departure/arrival times are within 3 minutes of midnight.
You might want to check for these special cases.


Cheers,
Rob


C4X wrote:
I am nearly finished working on my latest project, a data entry GUI in
VBA (2003), and have run into difficulties dealing with time values.


Brief project background: It is a simple data entry form which takes
various bits of flight data and enters them onto a spreadsheet. The
key entries I'm having trouble with are 'Time' values. Two fields are
automatically populated with the appropriate 'Departure' and 'Arrival'
times based on a 'ListIndex' run during initialization, which allows
values for the 'Flight Numbers'. An 'If...Then' statement refers back
to the 'ListIndex':


private sub fltNum_change
.....
If fltNum.ListIndex = 3 then * * 'Flight Number
* *fltFrom.value="nan" * * * * * * 'Departure airport
* *fltTo.value="suv" * * * * * * * * 'Arrival airport
* *fltATD.value="5:10" * * * * * * 'Departure time
* *fltATA.value="5:40" * * * * * * 'Arrival time
end if
.....
end sub


To allow the user to incrementally change the values, there are spin-
buttons with the following code that formats a time value:


private sub spinbutton3_SpinDown()
* *fltATD.text=format(timevalue(fltATD.text) - timevalue("00:01"),
"h:mm")
end sub


private sub spinbutton3_SpinUp()
* *fltATD.text=format(timevalue(fltATD.text) + timevalue("00:01"),
"h:mm")
end sub


This is where I lose the path :(


My next two (and final) goals elude me:
1) Display a value (value 'A') which is '3 minutes' less than the
'departure time' in a textbox with spin-button control, as well as a
value (value 'B') '3 minutes' more than the 'arrival time' in yet
another textbox with spin-button control.


2) Show a value which is value 'B' minus value 'A' in a textbox on the
userform in decimal-time format. I have the 4 values currently output
to a spreadsheet, and am able to easily subtract 'B' from 'A' and show
in a cell formatted with '=(E1-INT(E1))*24'. The correct decimal time
is shown, but I cant manage to show the value on my userform (and
subsequently allow the data to be entered onto the proper
spreadsheet).


Help please! :) If I can sort these two hurdles out, my project is
done.
Thnx
Clarke


Okay, thnx Rob. I have been staring at this off and on for a while
now. It gets blurry :) Should have worked that out. Anyways, we have
no flights around midnight, should be no prob there. Any thoughts on
how to format the total flight time as a decimal time (i.e: h.mm)? I
haven't come across it and the 'cell formula' I posted above is
unusable it seems . . .thnx.


Disregard, I missed it. Thnx again!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Issues cware Excel Discussion (Misc queries) 2 March 13th 09 05:32 PM
Issues with Time being converted to Date/Time format D[_10_] Excel Programming 1 February 28th 07 08:32 PM
formatting issues Olive Excel Worksheet Functions 0 September 22nd 06 02:22 PM
Time Issues LostNFound Excel Worksheet Functions 3 March 1st 05 01:10 PM
Run Time Issues Steph[_3_] Excel Programming 1 May 28th 04 06:50 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"