?
Solved

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

Posted on 2002-04-07
2
Medium Priority
?
134 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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

770 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