[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Time range that gets split (VB6)

Posted on 2008-11-13
12
Medium Priority
?
268 Views
Last Modified: 2012-05-05
Hi,

I've got two Times, start and end, and I'm trying to create a function where I pass in two other time parameters start1 and end1, the idea being that start1 and end1 get taken out of the original time ranges and after a few function calls I'm left with a few ranges that are excluded from the parameter times. For example:

Start time: 00:00
End time:   23:59

S1: 08:30
E1: 09:00

S2: 09:00
E2: 10:00

S3: 13:00
E3: 17:30

So the new times I'd have would change from 00:00 to 23:59 to these times:

Start1: 00:00:
End1:   08:30

Start2: 10:00
End2:   13:00

Start3: 17:30
End3:   23:59

I don't have any ideas on how I could implement this nicely - any ideas would be appreciated! :)

Thanks,
Uni
0
Comment
Question by:Unimatrix_001
  • 7
  • 4
12 Comments
 
LVL 11

Expert Comment

by:Louis01
ID: 22948588
Hi Uni

Some questions:
What kind of structure is the range you have in? A table, variables, array?
What kind of structure should the output be in?
Would it always be three sets?
Say S1 = New start time or E3 = new End Time or both; how should this be handled?

Thanks
Louis
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 22948603
Hi Louis,

Thanks for the response.

1) There isn't a structure at the moment. I've got two Date variables which indicate the start and end time.

2) I'm not too worried, but I'd like each start and end time to be represented as a Date variable.

3) No, it will probably be around 20 sets, but it will vary.

4) This will never happen, as nothing will occur at midnight or one minute to midnight so I'm happy for something like that to be undefined.

Thanks,
Uni
0
 
LVL 11

Expert Comment

by:Antagony1960
ID: 22949511
Funnily enough I'm planning to add a time range insertion function to an existing project of mine, but I've only really only started throwing it together and I've got other priorities at the moment. I've uploaded the form here if you want to check it out... it may give you some ideas.

It's very basic at the moment, I haven't even put any date/time variable in it yet... it's just using control arrays of Date/Time pickers configured for time ranges. The value of the added range is determined by the set values of the previous range, so it shouldn't be too difficult to adjust to your requirements. My plan (eventually) is to set the Max & Min values so that the user can't screw up the ranges and to tie the range "From" values in with the following range's "To" values--i.e. changing one automatically changes the other. As I say,it's very basic, but it may just set you on the right track.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:Unimatrix_001
ID: 22949527
Thank you - I'll have a little look at it. It may at least give me a starting point. :)
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 22949548
Hi Antagony, may I ask what version of VB you used here? The form object is a picturebox, yet the code refers to a ".Value" member, which doesn't exist in VB6?

Thanks,
Uni
0
 
LVL 11

Expert Comment

by:Antagony1960
ID: 22949664
It's VB6 (SP6)  Check your Help¦About menu to see which service pack you're on. If you're not on SP6 you'll need get that from the MS website first, as the date/time pickers are from the "Microsoft Windows Common Controls-2 6.0 (SP6)" components bundle. It's probably a good idea to be up to date with the latest service pack in any case.
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 22949773
Hi Antagony, I can't seem to get this working - would you mind giving me an overview of how things are working in your program?

Thanks,
Uni
0
 
LVL 11

Expert Comment

by:Antagony1960
ID: 22950080
Well it's really very simple at the moment, when a range is added it places a second set of date/time pickers underneath the last set (maximum 8 ranges at the moment) and sets their time values according to the values in the previous set and also changes the value of the previous range's "To" picker.

To2=To1
From2=From1+1min
To1=From2.

It really would be easier if you could get it working so that you can see for yourself. You can download SP6 here. But even if you can't get SP6 on your system at the moment, you should still be able to add the earlier (maybe buggy) date/time picker components to your toolbox, as they've been bundled with VB6 since its release (under "Microsoft Windows Common Controls-2 6.0").

Place one picker on the form and set the following properties:

Name: dtpFrom
Format: 3-dtpCustom
CustomFormat: HH:mm
UpDown: True

Copy and paste the first picker, saying "Yes" to control array

Rename the second picker to dtpTo and set its Index property to 0

Place them under the From & To labels (their Top properties should be 480) and it should run.

0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 22950194
I've got hold of SP6 and have added them to the VB form, but it is still getting a bit upset with the .Value property...
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 22950231
Actually, can you take a look at my new question - I should be able to get a good idea from what you've put to make it into Date objects:

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_23901800.html

Thanks,
Uni
0
 
LVL 11

Accepted Solution

by:
Antagony1960 earned 2000 total points
ID: 22950301
Value is definitely a property of the date/time picker. I suggest you remove the form from your project, re-extract the form from the zip file and then re-add it to you your project. It should work then. If not, post exactly what the error message is saying.
0
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 31516309
Cheers. :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question