Turn on thread page Beta
    • PS Helper
    • Thread Starter
    Offline

    13
    ReputationRep:
    PS Helper
    Ok I'm using VB6 to do my CPT6 coursework and to be honest I really can't program hence I'm asking for help.
    My project is on a hire boat company which has 7 boats which either start on a Friday, Saturday and Sunday.
    So my first, and currently main problem, is that I need to be able to generate the start dates for each boat so that they can be reserved and booked. Can anybody help me with how I could do this.
    Offline

    0
    ReputationRep:
    Well I'm not exactly sure what you mean but I can give you some information on using dates in VB.

    Say you type in this code:
    Msgbox Date

    The current date will pop up.

    'Date' in VB6 is todays date.

    Now what about this code:
    Msgbox Date + 1

    This will return tommorows date, starting to get the picture?

    Other useful date commands:
    Msgbox Month(Now)
    Msgbox Year(Now)

    The latter returns the current year, the former returns the current month. There returned as numbers by the way so you'll have to create some kind of code to translate them.

    Msgbox Year(Now + 1) (This code return the year for TOMMOROW since now is the same as date, both of them store todays date)

    Msgbox Year(Now) + 1 (This would return next year)

    You could GENERATE every date for the next 2 weeks using the following code:

    (I am assuming you wish to place them in a combobox called combo1)

    combo1.clear 'Clears combobox
    For i = 0 to 14 'Sets parameters for a loop
    combo1.additem Date + i 'Adds to the combo box the Date + i
    Next i

    Now if this isn't your cup of tea press CTRL + T and the component screen should come up. Select 'Microsoft Calendar Control 11.0' and press 'OK'.

    Stick a calendar control on your form and see the wonders of VB6.

    A word of warning for this control, before you start using it remember that to retrieve the month,day or year you MUST have a day selected on the control.

    Some useful stuff to know about the control:

    Msgbox Calendar1.Day

    Msgbox Calendar1.Month

    What the above two represent is quite clear, the current day on the calendar control and the current Month.

    I'll assume you are also using a database in your project, so you could do something like this:

    ReserveDate = Calendar1.Day & "/" & Calendar1.Month & "/" & Calendar1.Year

    And then add this date to your database.

    damn it parents woke up, well I'm dead ;rant;
    • PS Helper
    • Thread Starter
    Offline

    13
    ReputationRep:
    PS Helper
    That kind of helps. I probably haven't explained it very well though.
    Basically as I said I have 7 boats, 2 start on a Friday, 3 on a Saturday and 2 on a Monday. They can all be booked out for 1 or more weeks at a time. I need some kind of code that will allow me to generate a calender type thing for the current year and the next year. On the calender I need to be able to reserve a boat for a certain date, book a boat for a certain date and view which date have been booked and which are available. I also need a reservation to cancel if it hasn't been booked after 7 days.
    Edit: Forgot to say. To view the booked/avaiable boats it really needs to be on say a flexi grid or something similar so all booked available times can be seen for each boat at a time.
    Offline

    0
    ReputationRep:
    Is this for this year or next year?

    Either way I personally wouldn't recommend doing the whoel project in VB unless you're a pretty decent programmer to start with. You can get a good mark by doing a database and adding bits of VB onto that. It's crucial to do a good write-up - so IMO getting the project done (and it'll be quicker in Access) and freeing yourself for the write up is a lot safer - it's easy to get lost in a big codign project and then have to rush the write up

    There are functions in VB that allow you to find out what day of the week a particular date is - have a check under the help function.

    One alternative for the booking clash is to compare the desired booking dates with all the bookings you already have. It's pretty simple in Access but could be done in VB too.

    Just be aware that there are a number of ways that a clash can occur. If one booking is for (say) 15th-20th April, then all of the following will clash

    Edit:
    Just re-read your post - my example dates don't quite work if you have to book for a whole number of weeks (why limit it?) but the same point applies - there's more than one way to get an overlap and thus a booking clash.

    12th-16th April, 16th - 24th April, 16th-18th April, or 10th to 25th April, plus various others but those are the main categories. It's not just about another booking for 15th-20th April
    • PS Helper
    • Thread Starter
    Offline

    13
    ReputationRep:
    PS Helper
    It's for this year so most the first lot of paperwork has already been done. Also we have been told we have to do it in VB so I don't really have a choice about that.
    Offline

    1
    ReputationRep:
    How can they ask you to program in VB if you don't really know how to program?!

    Bah!
    Offline

    0
    ReputationRep:
    okay - it's possible they've changed the specification to insist on programming (I knw they've done that with the CPT3 project) but if not then I don't see how your teacher can insist. I think I'd query that!

    I don't see how you'll do a full project in a matter of days though if it's for this year - the project have to be with the exam board pretty soon I think?
    • PS Helper
    • Thread Starter
    Offline

    13
    ReputationRep:
    PS Helper
    Ours is due in two weeks today. And it is my own fault because I've left it quite late as I've been doing other coursework which was due in earlier (and is now finished).
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: April 17, 2008

University open days

  • University of Bradford
    All faculties Undergraduate
    Wed, 21 Nov '18
  • Buckinghamshire New University
    All Faculties Postgraduate
    Wed, 21 Nov '18
  • Heriot-Watt University
    All Schools Postgraduate
    Wed, 21 Nov '18
Poll
Black Friday: Yay or Nay?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.