资源描述:
《vb打印功能(vb printing function)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、vb打印功能(VBprintingfunction)UsingVBtoachievethequeryfunction,inordertoprintouttheresultsofthequery,howtoachieve?.Howshouldthespecificprogramstatementbewritten?printfromapplicationsVisualBasicprovidesthreetechniquesforprintingtextandgraphics.Youcanbuildthere
2、quiredoutputintheform,andthenprinttheformwiththePrintFormmethod.PrivateSubCommand1_Click()Me.PrintFormEndSubBysettingthedefaultprinterinthePrinterscollection,thetextandgraphicscanbesenttotheprinter....YoucansendtextandgraphicstoPrinterobjectsfirst,thenpri
3、ntthemwithNewPageandEndDocmethods.OptionExplicitPrivateyAsIntegerPrivatexAsIntegerPrivateTXTAsStringPrivatefntAsIntegerPrivateDDAsVariantPrintingfunctionPublicFunctionPRNT(x,As,y,As,FNT,As,TXT,As,Variant,Variant,Variant,Variant)Printer.CurrentX=xPrinter.C
4、urrentY=yPrinter.FontSize=fntPrinter.PrintTXTEndFunctionPrivateSubcmdPrint_Click()FNT=18Y=300X=500Txt="print""DD=PRNT(x,y,FNT,txt)Printer.EndDoc'printfinished.EndSubForexample,dataquery,pleaserefertothefollowingurl:Http://zhidao.baidu.com/question/4168806
5、.htmlVBIwanttoachievethepreviewfunctionbeforeprint,howtoachieve?Generallybythirdpartycontrols,VBitselfdoesnothavethisfeature,ofcourseIreferstotheVB5.0/6,ifyouareusingaVB2003/2005,therewillbeaprintpreviewfunction,butalsomoreperfectthanVB6printcontrol.Toach
6、ievetheprintfunction,youneedapublicdialogboxCommonDialog,intheengineeringmenu-component-selectMicrsoftcommondialogcontrol6Code:PrivateSubCommand1_click()CommonDialog1.ShowPrinterorCommonDialog1.Action=5EndWhatkindofprinteryoucanprintoutifyouhaveaprinter?P
7、rinterobjectThePrinterobjectcancommunicatewiththesystemprinterPrinterobjectscommonlyusedattributes:Height,width,PaperSize,DeviceName,respectively,indicatingthelengthofprintedpaper,width,sizeofpaper,printername.ThePrinterobjecthasthreeimportantmethods:EndD
8、oc,KillDoc(print)(interruptprinting)andNewPage(page).Forexample,thereisa"payattentionto26dayvirus"!"Itisnecessarytoprint10copies,addpagenumbers,andusethefollowingprocedures:PrivateSubcommand_Click()DimIAsIntegerDims