Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 9th, 2003, 10:44 PM
ric ric is offline
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default MSFlexGrid & Dates & other

HY, friends.

I have a database (data1.recordset) containing following relevant fields
shown within an MSFlexGrid:
.(“lastname”) ‘selfexplanatory
.(“arrivaldate”) as above
.(“departure”) as above
.(“roomno”) as number of room for an hotel

The row header shows dates for 365 days
The column header shows numbers of existing rooms

Now I need to fill the MSFlexGrid with lastnames into the proper dates/roomno cells
indicating the days a guest stay at the hotel.
To do so I have this code which have heavy problem and has to be remanipulated:

First of all loop in all records of data1
‘BEGIN
dim column as integer
dim row as integer
dim ind as integer


Data1.Recordset.MoveFirst

Do While Not Data1.Recordset.EOF

  ' looking for proper column (the date)
  column = DateDiff(“d”,Data1.Recordset.Fields(“arrival date”), MSFlexGrid1.TextMatrix(0, 0))

  ' looking for proper row (the room number)
  row = 0 ' row containing the cell to be filled

    For ind = 1 To MSFlexGrid1.Rows
        If MSFlexGrid1.TextMatrix(ind, 0) = Data1.Recordset.Fields(“roomno”) Then
            row = ind
            Exit For
        End If
    Next ind

    ' Filling the row of room with cells corresponding to days in which
‘client occupied it

    For ind = 1 To DateDiff("d", Data1.Recordset.Fields(“arrivaldate”), Data1.Recordset.Fields(“departure”))
        MSFlexGrid1.TextMatrix(row, column + ind - 1) = Data1.Recordset.Fields(“lastname”)
    Next ind

    Data1.Recordset.MoveNext
Loop
’END

I receive back error messages like: “interval not included …” … some “lastnames”
Appearing in the row headers, and so on.
This code has heavy problem.
Does anyone is so kind to suggest correction or a new one?
This will solve a vital problem and can’t by myself.
Thanks in advance.




 
Old December 10th, 2003, 05:47 AM
Authorized User
 
Join Date: Jun 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hard to say, but it has to be a problem with the row number.

You start by setting row to 0. Row 0 will contain your column headers. I your first for loop, if the criteria isn't met, then row will remain at 0. So when you then move to the next for loop setting the textmatrix, if row is 0, then your row header will be overwritten.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript && keeps turnig into && ayrton Pro VB.NET 2002/2003 3 June 27th, 2005 03:34 PM
send & recive mails from exchange & lotus sever zaheersharief Pro VB 6 1 May 16th, 2005 06:55 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
sql & join tables & find a field in multiple table trangd Beginning PHP 2 January 29th, 2004 07:18 PM
MSFlexGrid & correct pupulating ric VB Databases Basics 0 August 27th, 2003 10:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.