Solved

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

Posted on 2002-04-07
2
128 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
  • 2
2 Comments
 

Expert Comment

by:MayaOne
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

771 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

11 Experts available now in Live!

Get 1:1 Help Now