Results 1 to 14 of 14

Thread: DOS label Printing using VB

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    PUNE
    Posts
    222

    DOS label Printing using VB

    I have written code For Label Printing Using VB.
    am having 6 Lines to Print on Each Label which is printing From Excel File using ODBC.6 Lines are as Follows

    SimNo
    Mobileno
    Type Pkd On:
    Valid For
    MRP

    on the label paper there r 8 Rows & 3 Cols of labels.

    First User will type once Line 3,4,5 then Sim no & Mobile will be taken from Excel File.

    so how can i use DOS Based Printing to make it faster.
    & How can i manage space between two lables if User type the information in Caps Or Small
    am attaching my project pls see

    Thank You,
    Attached Files Attached Files

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: DOS label Printing using VB

    to print like dos mode use the C:\Prn like in
    VB Code:
    1. Dim iFreeFile As Integer
    2. iFreeFile = FreeFile()
    3. Open C:\Prn For Output As #iFreeFile
    4. Print #iFreeFile, "YourText Goes here"
    5. Close iFreeFile
    But if you have USB printer this will not work and the printer should be connected to the current system.
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    PUNE
    Posts
    222

    Re: DOS label Printing using VB

    How can i manage space if User Is typing Caps or Small ie ASCII
    how can i matter exactly on the Label as its contineous priniting for 20000 labels. on a paper there 24 labels (8 * 3)

    its DOS matrix Printer


    Thank You,

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

    Re: DOS label Printing using VB

    you can set tabs for your labels, use carriage return without line feed to print the next label text on the same row at the next tab, from the beginning of the line, so it is always in the same position, you need to check that no text is too long for the label width
    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

  5. #5
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,238

    Re: DOS label Printing using VB

    Quote Originally Posted by vaishali
    its DOS matrix Printer
    Don't you mean a Dot matix printer.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    PUNE
    Posts
    222

    Exclamation Re: DOS label Printing using VB

    I have tried with tabs but its not working as there r three label on each row.
    There r 8 rows * 3 Cols ir 24 labels on a paper.
    as labels papers are contineous stationary.

    How can i go with ASCII & manage space

    Thank You,

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    PUNE
    Posts
    222

    Re: DOS label Printing using VB

    & Paper size is 74mm By 34 mm

    Thank You,

  8. #8
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Jar, Norway
    Posts
    372

    Re: DOS label Printing using VB

    You need a Sub Routine like:
    VB Code:
    1. Sub print_Pos(lxPos As Single, rxPos As Single, yPos%, txt$)
    2.   If yPos > 0 Then Printer.CurrentY = yPos
    3.   Printer.CurrentX = rxPos - (rxPos - lxPos) / 2 - Printer.TextWidth(txt) / 2 ' /2 is Centering the txt
    4.   Printer.Print txt
    5. End Sub
    Last edited by Ember; Jan 2nd, 2007 at 08:28 AM.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    PUNE
    Posts
    222

    Exclamation Re: DOS label Printing using VB

    as there r three labels in Row
    so how can i centre out of each label


    Thank You

  10. #10
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Jar, Norway
    Posts
    372

    Re: DOS label Printing using VB

    The usage must be
    VB Code:
    1. print_Pos 0, (varible growing by 74mm),  (varible growing by 34mm)
    I had set lxPos=0 to keep the txt LeftAlign. But I did hope that you were willing to test out the values you send to this sub routine. I use an array for both growings. Like:
    VB Code:
    1. 'calculate vl array (vertical positions)
    2.   vl(1) = lMarg_W: col_W = ' equals to 74 mm
    3.   For i = 2 To 4
    4.     vl(i) = vl(i - 1) + col_W
    5.   Next
    and the same with hor. pos.

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

    Re: DOS label Printing using VB

    as you are printing directly to the printer in dos, you cannot use the vb printer object, the printer font will probably be a fixed width courier 10 (maybe with option of courier 12) (10 or 12 characters per inch) with esc codes to set bold wide or condensed etc so there are not many options the user can set, if you allow the user to choose font or size you need to print to the printer object and let widows print
    most printers were considered to be 80 column (or 132 for 11"), but when set to condensed could be 136 column

    using 10 as the default:
    as you have 3 labels across, each label is about 25 characters width, so you must restrict your text to about 20 characters and each label is approx 3" wide, so you can do something like this (not tested)

    VB Code:
    1. For i = 0 To countoflabelstoprint Step 3
    2.     Print #1, simno(i) & countspace(simno(i)) & simno(i + 1) & countspace(simno(i + 1)) & simno(i + 2)
    3.     Print #1, mobno(i) & countspace(mobno(i)) & mobno(i + 1) & countspace(mobno(i + 1)) & mobno(i + 2)
    4.     Print #1, tpo(i) & countspace(tpo(i)) & tpo(i + 1) & countspace(tpo(i + 1)) & tpo(i + 2)
    5.     Print #1, valf(i) & countspace(valf(i)) & valf(i + 1) & countspace(valf(i + 1)) & valf(i + 2)
    6.     Print #1, mrp(i) & countspace(mrp(i)) & mrp(i + 1) & countspace(mrp(i + 1)) & mrp(i + 2)
    7.     Print #1
    8. Next
    9.  
    10.  
    11. Function countspace(strlen As String)
    12.     countspace = Space(30 - Len(strlen))
    13. End Function

    you may need to adjust the number of spaces if 30 makes the gap too wide between labels and if they are to close vertically add another print #1
    you may need to check length of data, but that can be done at some other point (where the user input the data)

    in the unlikley event that your dot matrix printer does not use a fixed width font the string lengths can still be caclulated, but it is a bit more involved, if you are not using an inbuilt printer font then you are wasting your time as any windows font will need to be printed through the windows printer driver as a graphic (very slow)
    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

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    PUNE
    Posts
    222

    Re: DOS label Printing using VB

    May i handle this through Notepad
    so that if he wants to adjust the Label he can.

    How it can be done just guide me???

    Thank You,

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

    Re: DOS label Printing using VB

    pretty hard to do in notepad i think as all spacing depends on the fonts used
    easy in WORD where you can use tables
    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

  14. #14
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: DOS label Printing using VB

    Even easier in VB where you can use code to move the print head in steps of about .0694 inch (1 twp). It just takes a lot of measurements and calculations or a lot of trial and error to get it right. Or use the equivalent of an Avery label - something the label manufacturer provides printing software for. Access, for example, has a Label Wizard (create a new form) that "knows" a lot of commercially available label forms. (So, IIRC, does Crystal Reports.)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

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