Results 1 to 10 of 10

Thread: Printer Ideea

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    11

    Printer Ideea

    Hey,
    I need to know if there is any way that I can print a medical analisys report
    in visual basic:
    I have a form made with a lot of text boxes and a print button. When I press the print button I want the values from the text boxes to be printed. This is simple but formatting them is giving me problems. Example:

    Analyst Result Normal Values Analyst Result Normal values
    --------------------------------------------------------------------------
    Thymol Text1 2-4UML Prot C. Reactive TExt2 absent

    The main problem is that if I enter in Text1 a bigger value or something it will scramble all the allign. Some ideeas?

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Printer Ideea



    You can use Printer.CurrentX to print at "column" locations. e.g.

    Printer.Print "Thymol ";
    Printer.CurrentX = 900
    Printer.Print "some value"

    You may know this but the semi-colon causes the two things to be printed on the same line.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    11

    Re: Printer Ideea

    Hello MartinLiss,
    first of all thank you very much for your reply.
    I have learned a little about datagrid and if I Insert data from a textbox to a datagrid how do I print it? It will arrange the text in a more ordonated formating?

    If I use Printer.CurrentX what is the maximum value I can use? I mean what is the value that will mark the edge of the papaer? (I have wasted approx 200 A4 papers, I don't want to kill the forest anymore

    Tahnk you

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Printer Ideea

    "I have learned a little about datagrid and if I Insert data from a textbox to a datagrid how do I print it?" - You could do me.PrintForm but that may not be satisfactory since all the data would need to be visible and then you'd also have to first temporarily hide any controls that you didn't want in the picture.

    If I use Printer.CurrentX what is the maximum value I can use? - Offhand I don't know, but please reinsert the printed pages and/or turn them over and/or upside down

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Printer Ideea

    maximum value for currentX is printer.scalewidth
    anything printed at that position would move on to the next line
    i suggest using a pdf printer driver for testing purposes, you can just view on screen then overwrite for next test, test on real paper when the pdf is correct
    you have to work with the printer.textwidth to align your text into columns
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    11

    Re: Printer Ideea

    Ok. Thank you very much for your help.

    If I want to print in Visual Basic 2008 (I think is .net) a simple Hello world, what I must do? becase I have investigated this and is more complicated than printer.print Is something with documentprint. Can you provide me some kind of example on how to simply print on paper hello world? I have made it with the tables but I need to print Something else on the page.
    Thank you again

  7. #7

  8. #8
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Printer Ideea

    Quote Originally Posted by playplayply
    If I use Printer.CurrentX what is the maximum value I can use? I mean what is the value that will mark the edge of the paper? (I have wasted approx 200 A4 papers, I don't want to kill the forest anymore

    Tahnk you
    Use the PrintPreview dialog for printing tests, never ever use paper for all of the testing
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  9. #9

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    11

    Re: Printer Ideea

    OK. But how can I print Hello world on the paper?

  10. #10
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Printer Ideea

    Drop a PrintDocument on the form, double click it now in the code window you'll see a PrintPage event has been put in, use e.Graphics.DrawString() to draw the text on the page.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width