Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

Reports in VB 6.0 with Proprietary files

I have an app that use proprietry file formats so it does not connect to a database.  I used the format:

    TaMainLineBuffer = Input$(Len(CurrEval), #fileno)

 to read the files into a UDT and then manipulate the fields.

To write the files I use:

      Print #OutputFileNo, savebuffe)

The tables are .txt files with data in the files stored in encrypted format.

My user has requested more elaborate reports from the application.  Up to this point we have been using 'PrintForm' to generate hard copy output.

All that I have seen about the VB report generator include the first step up setting up a data environment.  Once the data environment is established the 'report generator' can be used.  Is it possible to set up a data environment using these proprietary file formats?  If not what are my options for creating reports.?  I know that I can create custom forms in the format of the printed output and still resort to using 'Printform' for send them to hard copy but I was looking for a better option.  The existing forms are very involved and the idea of duplicating them (with certain changes) for print is not very appealing.

This app is distributed to the client as an .EXE so any report writing would have to work in that context.  I would not have a valid license, not does the client wish to purchase one for any external report writers (Crystal etc...)

I don't think that I have many options here but that is why I am asking the experts.
ASKER CERTIFIED SOLUTION
Avatar of gimmeadrink
gimmeadrink

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mlcktmguy

ASKER

Thanks for the feedback.  I just read your comment and have not had a chance to try it.  I noticed that you had an example generating graphs using MSchart.  I would be most interested in that example also.  One of the long term goals of the users is the ability to create grahical output from this system.

Thanks again.

Avatar of gimmeadrink
gimmeadrink

ok, ill try and dig it up sometime today

let me know how the report stuff goes
gimmeadrink,
The report stuff went fine.  I have a lot to learn about the report writer.  Do you know of any links to help with tha?  Your answer is exactly what I was looking for and I'm going to award you the points.   I am still very interested in generating graphical chart output using mschart.  If you can find those examples I would be most appreciative.

Thanks
Hi,

Sorry I have not got back to you yet, been doing 19 hour days at work in the last couple of days and havnt found a lot of time... it might not be until the weekend that i dig it up. If i dont respond, just keep on bugging me with messages... it works when i do it to other ppl, so i imagine it will work on me too ;)

Thanks for the points and the A, glad i could help so far.
Any luck with the mschart examples?
i will have a look now..... got a day off :D
Okay, this example may be a bit more complex than you need, but im sure u can get the jist of it and apply it with your own data....


' some globals that are relevant
Dim arrData(6, 1 To 3) As Variant
Dim arrTrans(6) As Boolean
Dim dayData(7, 1 To 19) As Variant

' initialisation of the arrays....




Public Sub InitiateDataValues()
    ' PRE:  arrData has been instantiated
    ' POST: arrData will have chart information
   
    arrData(1, 1) = "F. Disp."
    arrData(2, 1) = "F. Vel."
    arrData(3, 1) = "F. Acc."
    arrData(4, 1) = "E. Disp."
    arrData(5, 1) = "E. Vel."
    arrData(6, 1) = "E. Acc."
   
    arrData(1, 2) = 0
    arrData(2, 2) = 0
    arrData(3, 2) = 0
    arrData(4, 2) = 0
    arrData(5, 2) = 0
    arrData(6, 2) = 0
   
    arrData(1, 3) = 0
    arrData(2, 3) = 0
    arrData(3, 3) = 0
    arrData(4, 3) = 0
    arrData(5, 3) = 0
    arrData(6, 3) = 0
   
    dayData(1, 1) = "Day 1"
    dayData(2, 1) = "Day 2"
    dayData(3, 1) = "Day 3"
    dayData(4, 1) = "Day 4"
    dayData(5, 1) = "Day 5"
    dayData(6, 1) = "Day 6"
    dayData(7, 1) = "Day 7"
   
    Dim j As Integer
    Dim i As Integer
   
    For i = 1 To 7
        For j = 2 To 19
            dayData(i, j) = 0
        Next
    Next
End Sub


''''''''''''''''''''
'The sub that formats the chart based on data....

Public Sub LineChart(chart As MSChart, arrayOfData() As Variant, arrayOfTransgressions() As Boolean, Optional data2 As Boolean = False, Optional data3 As Boolean = False, Optional numberOfDays As Integer = 7)

    ' PRE:  To Do
    '       when numberOfComparisons is 0 there is only one set of data
    '       data2 and data3 are true iff chkCompare2 and chkCompare3 are true respectively
    ' POST: To Do
    '       Generates the data for the Days-Graph (Tab 2-1) then needs to be tidied. (Tidy Chart sub)

    Dim Data() As Variant
    Dim numberOfComparisons As Integer
    Dim countOrig As Integer
    Dim countNew As Integer
    countNew = 0
    For countOrig = 1 To 6
            If arrayOfTransgressions(countOrig) = True Then
                countNew = countNew + 1
            End If
    Next
    numberOfComparisons = 1
    If data2 Then
        numberOfComparisons = numberOfComparisons + 1
    End If
    If data3 Then
        numberOfComparisons = numberOfComparisons + 1
    End If
    If countNew = 0 Then
       ' abort, there should not be any graph displayed
        chart.Visible = False
        txtChart2.Visible = True
        Exit Sub
    Else
        ' make sure that the graph is visible
        chart.Visible = True
        txtChart2.Visible = False
    End If
   
    With chart
        .chartType = VtChChartType2dLine
       
        ReDim Data(numberOfDays, numberOfComparisons * countNew + 1)
        Dim totalCount As Integer
        totalCount = countNew
        .ShowLegend = False
       
        Dim dayNumber As Integer
        For dayNumber = 1 To numberOfDays
            ' Do Day names first
            Data(dayNumber, 1) = arrayOfData(dayNumber, 1)
            countNew = 0
            For countOrig = 1 To 6
                If arrayOfTransgressions(countOrig) = True Then
                    countNew = countNew + 1
                    Data(dayNumber, 1 + countNew) = arrayOfData(dayNumber, 1 + countOrig)
                    If data2 Then
                        Data(dayNumber, 1 + countNew + totalCount) = arrayOfData(dayNumber, 7 + countOrig)
                    End If
                    If data3 Then
                        If data2 Then
                            Data(dayNumber, 1 + countNew + totalCount * 2) = arrayOfData(dayNumber, 13 + countOrig)
                        Else
                            Data(dayNumber, 1 + countNew + totalCount) = arrayOfData(dayNumber, 13 + countOrig)
                        End If
                    End If
               
                End If
            Next
        Next
       
        .ChartData = Data
        .RowCount = numberOfDays
        .ColumnCount = numberOfComparisons * countNew
        .Refresh
    End With

End Sub



' This is how it was called....
LineChart chtDay, dayData, arrTrans, chkCompare2 = 1, chkCompare3 = 1, CInt(cmbNumDays1)

----------------------------------------
You can pretty much strip the arrayOfTransgressions stuff... its not important for you.

The key part for you is to the end of the WITH area...

        .ChartData = Data
        .RowCount = numberOfDays
        .ColumnCount = numberOfComparisons * countNew
        .Refresh

you just need a multidimensional array of data
set the rows and counlns
and refresh

Just let me know if its a bit confusing, i just thought i would rather use a working example than strip something out only to stuff it up.

Cheers,

Todd.