home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / bar_vbx / form1.frm < prev    next >
Text File  |  1993-12-22  |  7KB  |  268 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "BarCode/VBX Sample"
  4.    ClientHeight    =   3336
  5.    ClientLeft      =   900
  6.    ClientTop       =   1920
  7.    ClientWidth     =   5856
  8.    Height          =   3756
  9.    Left            =   852
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3336
  12.    ScaleWidth      =   5856
  13.    Top             =   1548
  14.    Width           =   5952
  15.    Begin BarCode BarCode2 
  16.       BarCodeType     =   0  'Code 3 of 9
  17.       Checksum        =   0
  18.       Height          =   672
  19.       Left            =   4500
  20.       NarrowBarWidth  =   2
  21.       Ratio           =   0  '3:1
  22.       Rotation        =   0  'Normal
  23.       Text            =   ""
  24.       Top             =   600
  25.       Visible         =   0   'False
  26.       Width           =   1212
  27.    End
  28.    Begin CommandButton Command3 
  29.       Caption         =   "P&rint Printer"
  30.       Height          =   432
  31.       Left            =   3720
  32.       TabIndex        =   6
  33.       Top             =   2760
  34.       Width           =   1992
  35.    End
  36.    Begin CommandButton PrintFormBtn 
  37.       Caption         =   "Print &Form"
  38.       Height          =   432
  39.       Left            =   1860
  40.       TabIndex        =   5
  41.       Top             =   2760
  42.       Width           =   1752
  43.    End
  44.    Begin CommandButton Command2 
  45.       Caption         =   "&Bound Sample..."
  46.       Height          =   432
  47.       Left            =   60
  48.       TabIndex        =   4
  49.       Top             =   2160
  50.       Width           =   1692
  51.    End
  52.    Begin CommonDialog CMDialog1 
  53.       CancelError     =   -1  'True
  54.       Left            =   5280
  55.       PrinterDefault  =   0   'False
  56.       Top             =   60
  57.    End
  58.    Begin CommandButton Command1 
  59.       Cancel          =   -1  'True
  60.       Caption         =   "&Cancel"
  61.       Height          =   432
  62.       Left            =   1860
  63.       TabIndex        =   2
  64.       Top             =   2160
  65.       Width           =   1752
  66.    End
  67.    Begin BarCode BarCode1 
  68.       BarCodeType     =   0  'Code 3 of 9
  69.       Checksum        =   0
  70.       Height          =   672
  71.       Left            =   180
  72.       NarrowBarWidth  =   2
  73.       Ratio           =   0  '3:1
  74.       Rotation        =   0  'Normal
  75.       Text            =   ""
  76.       Top             =   600
  77.       Width           =   3456
  78.    End
  79.    Begin CommandButton Print 
  80.       Caption         =   "&Print w/Selection"
  81.       Height          =   432
  82.       Left            =   60
  83.       TabIndex        =   1
  84.       Top             =   2760
  85.       Width           =   1692
  86.    End
  87.    Begin TextBox Text1 
  88.       FontBold        =   0   'False
  89.       FontItalic      =   0   'False
  90.       FontName        =   "MS Sans Serif"
  91.       FontSize        =   9.6
  92.       FontStrikethru  =   0   'False
  93.       FontUnderline   =   0   'False
  94.       Height          =   360
  95.       Left            =   120
  96.       TabIndex        =   0
  97.       Text            =   "Text1"
  98.       Top             =   180
  99.       Width           =   3072
  100.    End
  101.    Begin Label Label1 
  102.       Caption         =   "Double Click on BarCode to set Properties."
  103.       Height          =   312
  104.       Left            =   60
  105.       TabIndex        =   3
  106.       Top             =   1620
  107.       Width           =   4332
  108.    End
  109. End
  110.  
  111. Sub BarCode1_DblClick ()
  112.     Form2.Show 1
  113. End Sub
  114.  
  115. Sub Command1_Click ()
  116.     End
  117. End Sub
  118.  
  119. Sub Command2_Click ()
  120.     Form3.Show 1
  121. End Sub
  122.  
  123. Sub Command3_Click ()
  124.     BarCode1.PrinterTop = 50
  125.     BarCode1.PrinterLeft = 0
  126.     BarCode1.PrinterHeight = 100
  127.     BarCode1.PrinterBarWidth = BarCode1.NarrowBarWidth * 2
  128.     BarCode1.PrinterHDC = Printer.hDC
  129.     If BarCodeGetLastErrorCode() <> False Then
  130.     MsgBox BarCodeGetLastErrorString()
  131.     End If
  132.  
  133.     Printer.CurrentX = 0
  134.     Printer.CurrentY = 0
  135.     Printer.Print "Part Number";
  136.  
  137.     Printer.CurrentX = 5000
  138.     Printer.Print "Serial Number";
  139.  
  140.     BarCode1.PrinterLeft = 835
  141.     BarCode1.PrinterHDC = Printer.hDC
  142.     If BarCodeGetLastErrorCode() <> False Then
  143.     MsgBox BarCodeGetLastErrorString()
  144.     End If
  145.  
  146.     Printer.NewPage
  147.     Printer.EndDoc
  148. End Sub
  149.  
  150. Sub Form_Load ()
  151.     Text1.Text = "123456"
  152. End Sub
  153.  
  154. Sub Print_Click ()
  155.     Dim DOCINFO As DOCINFO
  156.     Dim StopPrint As Integer
  157.     Dim OutStr As String
  158.     Dim hOldFont As Integer
  159.     Dim theScaleMode As Integer
  160.  
  161.     StopPrint = False
  162.     On Error GoTo PrintErr:
  163.                    
  164.     CMDialog1.Flags = PD_RETURNDC Or PD_PRINTSETUP
  165.     CMDialog1.Action = 5
  166.     
  167.     If StopPrint = False Then
  168.     Screen.MousePointer = 11
  169.     theScaleMode = 6 ' Millimeters
  170.  
  171.     CreateObjects
  172.  
  173.     DOCINFO.cbSize = 0
  174.     DOCINFO.DocName = 0
  175.     DOCINFO.Output = 0
  176.  
  177.     Ok = StartDoc(CMDialog1.hDC, DOCINFO)
  178.     Ok = StartPage(CMDialog1.hDC)
  179.  
  180.     hOldFont = SelectObject(CMDialog1.hDC, hTextFont)
  181.  
  182.     PrintText CMDialog1.hDC, "Part Number (P)", 0, 0, hTextFont, theScaleMode
  183.     PrintText CMDialog1.hDC, "123-ABC", 0, 4, hDataFont, theScaleMode
  184.  
  185.     BarCode2.BarCodeType = 0
  186.     BarCode2.Text = "P" & "123-ABC" & Chr(0)
  187.     BarCode2.PrinterTop = 13
  188.     BarCode2.PrinterLeft = 0
  189.     BarCode2.PrinterHeight = 12
  190.     BarCode2.PrinterBarWidth = 4
  191.     BarCode2.PrinterScaleMode = theScaleMode
  192.     BarCode2.PrinterHDC = CMDialog1.hDC
  193.     If BarCodeGetLastErrorCode() <> False Then
  194.         MsgBox BarCodeGetLastErrorString()
  195.     End If
  196.  
  197.     PrintText CMDialog1.hDC, "Serial Number (S)", 85, 0, hTextFont, theScaleMode
  198.     PrintText CMDialog1.hDC, "987654", 85, 4, hDataFont, theScaleMode
  199.  
  200.     BarCode2.BarCodeType = 0
  201.     BarCode2.Text = "S" & "987654" & Chr(0)
  202.     BarCode2.PrinterTop = 13
  203.     BarCode2.PrinterLeft = 85
  204.     BarCode2.PrinterHeight = 12
  205.     BarCode2.PrinterBarWidth = 4
  206.     BarCode2.PrinterHDC = CMDialog1.hDC
  207.     If BarCodeGetLastErrorCode() <> False Then
  208.         MsgBox BarCodeGetLastErrorString()
  209.     End If
  210.  
  211.     PrintText CMDialog1.hDC, "P.O. Number (N)", 0, 30, hTextFont, theScaleMode
  212.     PrintText CMDialog1.hDC, "546789", 0, 34, hDataFont, theScaleMode
  213.  
  214.     BarCode2.BarCodeType = 0
  215.     BarCode2.Text = "N" & "546789" & Chr(0)
  216.     BarCode2.PrinterTop = 42
  217.     BarCode2.PrinterLeft = 0
  218.     BarCode2.PrinterHeight = 12
  219.     BarCode2.PrinterBarWidth = 4
  220.     BarCode2.PrinterHDC = CMDialog1.hDC
  221.     If BarCodeGetLastErrorCode() <> False Then
  222.         MsgBox BarCodeGetLastErrorString()
  223.     End If
  224.  
  225.     PrintText CMDialog1.hDC, "ABC Corporation", 85, 42, hCompanyFont, theScaleMode
  226.     PrintText CMDialog1.hDC, "123 Street Address", 85, 46, hCompanyFont, theScaleMode
  227.     PrintText CMDialog1.hDC, "Anywhere, USA", 85, 50, hCompanyFont, theScaleMode
  228.  
  229.     Ok = SelectObject(CMDialog1.hDC, hPen)
  230.  
  231.     MoveToScale CMDialog1.hDC, 80, 0, theScaleMode
  232.     LineToScale CMDialog1.hDC, 80, 55, theScaleMode
  233.  
  234.     MoveToScale CMDialog1.hDC, 0, 28, theScaleMode
  235.     LineToScale CMDialog1.hDC, 155, 28, theScaleMode
  236.  
  237.     Ok = EndPage(CMDialog1.hDC)
  238.     Ok = EndDocAPI(CMDialog1.hDC)
  239.     Ok = SelectObject(CMDialog1.hDC, hOldFont)
  240.     DeleteObjects
  241.     Ok = DeleteDC(CMDialog1.hDC)
  242.  
  243.     Screen.MousePointer = 0
  244.     End If
  245.  
  246.     On Error GoTo 0
  247. Exit Sub
  248.  
  249. PrintErr:
  250.     StopPrint = True
  251.     Resume Next
  252. End Sub
  253.  
  254. Sub PrintFormBtn_Click ()
  255.     Form4.PartNumber.Text = "123456"
  256.     Form4.PartBarCode.Text = "P" & Form4.PartNumber.Text
  257.     Form4.SerialNumber.Text = "230549"
  258.     Form4.SerialBarCode.Text = "S" & Form4.SerialNumber.Text
  259.     Form4.PONumber.Text = "345634-DF"
  260.     Form4.POBarCode.Text = "N" & Form4.PONumber.Text
  261.     Form4.PrintForm
  262. End Sub
  263.  
  264. Sub Text1_Change ()
  265.     BarCode1.Text = Text1.Text
  266. End Sub
  267.  
  268.