Solved

Printing the values of the controls in a from [with Printer object]

Posted on 2002-04-07
2
133 Views
Last Modified: 2010-05-03
Hi,
I have a problem in printing the values of all the controls of a form ,in a printer.I have a list view control in the form.I want to print all the values in that list view control.
The problem is while looping through all the values in that control,I facing the allignement problem.The output is well - alligned ,while Iam printing in the debug window.But it is not alligned ,while printed on a paper.Iam using the Printer object for this.What can I do now? Is there any other solution ?

----My code is ----
'objList - list view
'Variable declarations trimmed here.
'Totally I have 7 column headers in the list view.

    For intCount = 1 To objLst.ListItems.Count
           If intCountHd = 1 Then
               strCol1 = Trim(objLst.ListItems(intCount).Text)
               intSpace = FindDiff(arrColLen(intCountHd), Len(strCol1))
               intSpace = intSpace + intConst
               intSpace1 = intSpace
           Else
                Select Case intCountHd
                    Case 5
                      strCol1 = Trim(objLst.ListItems(intCount).ListSubItems(intCountHd - 1).Text)
                      intSpace = FindDiff(arrColLen(intCountHd), Len(strCol1))
                      intSpace = intSpace + intConst
                      intSpace1 = intSpace
                    Case 2, 6
                      strCol2 = Trim(objLst.ListItems(intCount).ListSubItems(intCountHd - 1).Text)
                      intSpace = FindDiff(arrColLen(intCountHd - 1), Len(strCol1))
                      intSpace = intSpace + intConst
                      intSpace2 = intSpace
                    Case 3, 7
                      strCol3 = Trim(objLst.ListItems(intCount).ListSubItems(intCountHd - 1).Text)
                      intSpace = FindDiff(arrColLen(intCountHd - 1), Len(strCol2))
                      intSpace = intSpace + intConst
                      intSpace3 = intSpace
                    Case 4
                      strCol4 = Trim(objLst.ListItems(intCount).ListSubItems(intCountHd - 1).Text)
                      intSpace = FindDiff(arrColLen(intCountHd - 1), Len(strCol3))
                      intSpace = intSpace + intConst
                      intSpace4 = intSpace
                End Select
           End If
           
       Next
          Print #1, strCol1 & Space(intSpace2) & strCol2 & Space(intSpace3) & strCol3 & Space(intSpace4) & strCol4
          'Printer.Print strCol1; Chr(9); strCol2; Chr(9); strCol3; Chr(9); strCol4
          'Printer.Print strCol1, strCol2, strCol3, strCol4
    Next
 --------------------------------------
Before this ,I will be printing the column headers,each separated by a space of 10.

Thanx in Advance & Appreciations for Ur valuable suggestions.

0
Comment
Question by:ashok73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Expert Comment

by:MayaOne
ID: 6924812
Hi!

I think, you can set the font of the printer object to a
fixed width font (like arial) and that should resolve your problem
0
 

Accepted Solution

by:
MayaOne earned 100 total points
ID: 6924841
Uups my mistake!

In the last comment i wrongly say that arial was a fixed width font, well... it isn't. the most common fixed with font in the diferent versions of ms windows seems to be the Courier

sorry!
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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