Solved

Reports in VB 6.0 with Proprietary files

Posted on 2004-09-26
8
191 Views
Last Modified: 2013-11-25
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.
0
Comment
Question by:mlcktmguy
  • 5
  • 3
8 Comments
 
LVL 2

Accepted Solution

by:
gimmeadrink earned 250 total points
ID: 12155053
Hi

You said you can get a UDT out of the data using readline.

From there you can create a temporary Recordset and apply rs.Fields.Append to dynamically generate the recordset with values from the UDT instead of it being databound. You then set the datasounce and other parts of the report designer to the temporary record set you have generated.

You can also generate graphs using mschart and dynamically add them (this example doesnt cover that but i have some code from a few years ago that i can dig up if you want).

The following example shows you how to do this...

http://www.freevbcode.com/ShowCode.asp?ID=6335


I hope this helps.

Let me know if you have any questions

Note: the report designer is included within the VB package and therefore wont cost you anymore.
Note2: if you have problems with distribution (although i dont think that you will require any additional dlls/ocx than already included in most standard vb apps) then try the 'package and deployment wizard' that is part of visual studio (u can find it somewhere in the visual studio menu in start->programs). It will create a msi and install any dependancies.
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12155749
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.

0
 
LVL 2

Expert Comment

by:gimmeadrink
ID: 12156457
ok, ill try and dig it up sometime today

let me know how the report stuff goes
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12175218
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
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 2

Expert Comment

by:gimmeadrink
ID: 12175288
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.
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 12220539
Any luck with the mschart examples?
0
 
LVL 2

Expert Comment

by:gimmeadrink
ID: 12222104
i will have a look now..... got a day off :D
0
 
LVL 2

Expert Comment

by:gimmeadrink
ID: 12222595
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.

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

3 Tips For Quarter Milers: A Sprinter's Understanding of Agile Software Development Two years ago, I wrote a blog entry about Agile software development (http://www.experts-exchange.com/blogs/mwvisa1/B_1770-Agile-Software-Development.html). At th…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now