Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Printing in .net

Printing in .net

Scheduled Pinned Locked Moved Visual Basic
csharptutorialquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    No e
    wrote on last edited by
    #1

    I had a vb6 project I am upgrading, in that project I had a subroutine that I used to print results such that a string of data would appear in a different column. The end result being an example as illustrated below (the 'Y's are passed as a string and this procedure wrapped them.) Not real pretty but it worked if a fixed font was used. sample output: (the Y string is actually a series of numbers separated by commas) XXXXX YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY ZZZZ YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY the code:

    Sub subPrintResults(slot As Integer, toPrint As String, Result As String, qty As Integer)

    Dim i As Integer
    Dim chr As String
    Printer.CurrentX = 2000             ' first place to results line
    Printer.Print Result;  ' this is the 'XXXXX in the example above
    Printer.CurrentX = 3000
    
    'if we have a long string
    If Len(toPrint) > 90 Then
        i = 0                           ' look for last comma, starting back 1
        Do Until chr = ","
            chr = Mid$(toPrint, 90 - i, 1)
            i = i + 1
        Loop
        Printer.Print Mid$(toPrint, 2, 90 - i)
        Printer.CurrentX = 3000
        Printer.Print Mid$(toPrint, 90 - i + 2, Len(toPrint) - 90 - i + 1);
    Else
        Printer.Print Mid$(toPrint, 2, Len(toPrint) - 2);    
    End If
    Printer.CurrentX = 10000
    Printer.Print Format$(qty, "@@@@@")
    

    Exit Sub

    Can anyone point me to a way to determine the length of a string in vb .net to be output so I can reproduce this type of functionality? Thanks No-e edit looks like the alignment in my example was thrown off when I posted, all the YYYYs in the example should be in a single column.

    H 1 Reply Last reply
    0
    • N No e

      I had a vb6 project I am upgrading, in that project I had a subroutine that I used to print results such that a string of data would appear in a different column. The end result being an example as illustrated below (the 'Y's are passed as a string and this procedure wrapped them.) Not real pretty but it worked if a fixed font was used. sample output: (the Y string is actually a series of numbers separated by commas) XXXXX YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY ZZZZ YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY the code:

      Sub subPrintResults(slot As Integer, toPrint As String, Result As String, qty As Integer)

      Dim i As Integer
      Dim chr As String
      Printer.CurrentX = 2000             ' first place to results line
      Printer.Print Result;  ' this is the 'XXXXX in the example above
      Printer.CurrentX = 3000
      
      'if we have a long string
      If Len(toPrint) > 90 Then
          i = 0                           ' look for last comma, starting back 1
          Do Until chr = ","
              chr = Mid$(toPrint, 90 - i, 1)
              i = i + 1
          Loop
          Printer.Print Mid$(toPrint, 2, 90 - i)
          Printer.CurrentX = 3000
          Printer.Print Mid$(toPrint, 90 - i + 2, Len(toPrint) - 90 - i + 1);
      Else
          Printer.Print Mid$(toPrint, 2, Len(toPrint) - 2);    
      End If
      Printer.CurrentX = 10000
      Printer.Print Format$(qty, "@@@@@")
      

      Exit Sub

      Can anyone point me to a way to determine the length of a string in vb .net to be output so I can reproduce this type of functionality? Thanks No-e edit looks like the alignment in my example was thrown off when I posted, all the YYYYs in the example should be in a single column.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Take a look at the Graphics.MeasureString() method.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      N 1 Reply Last reply
      0
      • H Henry Minute

        Take a look at the Graphics.MeasureString() method.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        N Offline
        N Offline
        No e
        wrote on last edited by
        #3

        Very cool, thanks for the pointer. I did not realize it was there. I guess this is part of my learning curve so to speak :) No-e

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups