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
Solved

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

Posted on 2002-04-07
2
131 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 127
bit defender blocks good applications 2 101
Automatic Email Reminder 4 57
Sub or Function is not defined 6 43
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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

856 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