《《条码技术》课程设计--Code25码生成与识别程序设计.docx》由会员分享,可在线阅读,更多相关《《条码技术》课程设计--Code25码生成与识别程序设计.docx(10页珍藏版)》请在优知文库上搜索。
1、条码技术课程设计题目Code25码生成与识J不辨蝴专业包装工程一、课程设计目标3二、程序界面设计3三、程序代码设计4四、程序运行结果9五、设计心得体会10一、程序设计目标任选一种条码码制(39码除外),编程实现条码的生成、打印、存储、打开、识别等功能。(利用CorelDraw软件生成不同码制的条形码符号。熟悉VB编程环境下的一些基本操作和基本编程语言。利用VB编写程序实现条码的生成。利用VB编写程序实现条码的识别。)二、程序界面设计程序界面设计应该包括绘图、条码编译、打开图片、保存图片、打印、清空等基本内容。三、程序代码设计程序代码的内容:OptionExplicitPrivateCharSt
2、ringAsStringPrivatest(OTo9)AsStringPrivateCheckStringAsStringDimbarTextAsStringDimMaxX,MaxYAsIntegerDimStartX,StartY,EndX,EndYAsIntegerDimBSStringAsStringDimDataStringAsStringDimFileNameAsIntegerPrivateSubform_load()CharString=0123456789”St(O)=uOOllO0st(l)=1000,1st(2)=0100,“2st(3)=uIlOOOn,3st(4)=001
3、0,4st(5)=uIOlOOn,5st(6)=01100,6st(7)=00011,7st(8)=10010,8st(9)=uOlOlOnn9FileName=1EndSubPrivateSubCommand1_Click()barText=TextLTextPictureLClsDims,eAsInteger”起始符与终止符Dimi,j,K,c,x,yAsIntegerMaxX=0MaxY=0x0=40yO=3O”起始符Fors=1To3Picturel.Line(x,y)-(x,y+100*HScroll1.Value)x=x+1Nextsx=x+1Fors=1To3PictureLLi
4、ne(x,y)-(x,y+100*HScroll1.Value)x=x+1Nextsx=x+1PictureLLine(x,y)-(x,y+I(X)*HScroll!.Value)x=x+2”条码DimCtrlStringAsStringForK=1ToLen(barText)CtrlString=st(InStr(l,0123456789,Mid(barText,K,1)-1)Fori=1To5c=Int(Mid(CtrlString,i,1)Ifc=1Then”画宽条Forj=1To3*HScroll1.ValuePictureLLine(x,y)-(x,y+100*HScroHl.Val
5、ue)x=x+1NextjElsePictureLLine(x,y)-(x,y+100*HSCrOlII.Value)”画窄条x=x+1EndIfx=x+1”画空NextiNextK”终止符Fors=1To3PictureLLine(x,y)-(x,y100*HScroll!.Value)x=x+1NextSx=x+1PictureLLine(x,y)-(x,y+I(X)*HScrolll.Value)x=x+2Fors=1To3PictureLLine(x,y)-(x,y+I(X)*HScrolll.Value)x=x+1Nextsx=x+1MaxX=Picturel.CurrentX+30
6、MaxY=PictureLCurrentY+30EndSubPrivateSubpicture1_MouseDown(buttonAsInteger,shiftAsInteger,xAsSingle,yAsSingle)StartX=xStartY=yBSString=,n,EndSubPrivateSubpicture1_MouseMove(buttonAsInteger,shiftAsInteger,xAsSingle,yAsSingle)Ifbutton=1ThenPictureLLine(StartX,StartY)-(x,StartY),vbRedPictureLLine(Start
7、X,StartY+l)-(x,StartY+1),vbRedPictureLLine(StartX,StartY+2)-(x,StartY+2),vbRedEndIfEndSubPrivateSubCommand4_Click()DimCommonDialoglSetCommonDialogl=CreateObject(,MSComDlg.CommonDialog)CommonDialog1.FileName=,n,CommonDialogLFilter=nJPG图片(*.JPG)*.jpgBMP图片(*.BMP)*.bmpICO图标(*.1CO)I*.icoGlF图片(*.GlF)*.gif
8、uCommonDialog1.ShowSaveIfCommonDiaIogLFileName,uThenSavePicturePicturelJmage,CommonDiaIogl.FileNameEndSubPrivateSubpicture1_MouseUp(buttonAsInteger,shiftAsInteger,xAsSingle,yAsSingle)EndX=xEndY=yBSString=|,DimiAsIntegerDimcolAsColorConstantsFori=StartXToEndXcol=Picturel.Point(i,StartY-1)Ifcol10ThenB
9、SString=BSString&0ElseBSString=BSString&1EndIfNextCommand2_ClickEndSubPrivateSubCommand2_Click()DimStempAsStringDimc,i,j,KAsIntegerDimtemp(OTo4)AsStringBSString=Mid(BSString,InStr(l,BSString,1),Len(BSString)去前空白区OFori=Len(BSString)To1SteP-去后空白区OIfMid(BSString,i,l)0ThenBSString=Mid(BSString,1,i+1)Exi
10、tForEndIfNextK=Oc=0Forj=11ToLen(BSString)-10IfMid(BSString,j,1)=0Andc3Thentemp(K)=OK=K+1c=0ElseIfMid(BSString,j,1)=0Andc=3Thentemp(K)=1K=K+1c=0ElseIfMid(BSStringJ,1)=1Andc3Thenc=c+1EndIfIfK=5ThenK=OStemp=,Stemp=temp(0)&temp(1)&temp(2)&temp(3)&temp(4)Fori=0To9Ifst(i)=StempThenDataString=DataString&Mi
11、d(CharString,i+1,1)EndIfNextiEndIfNextjMSgBOX条码符号表示的信息为:&vbCrLf&DataStringDataString=EndSubPrivateSubCommand3_Click()PictureLClsDimoDLGSetoDLG=CreateObject(MSComDlg.CommonDialogu)WithoDLG.DialogTitle=打开文件”.Filter=图片文件|*Jpg;*.bmp;*.tiF.Filterindex=1.MaxFileSize=255.ShowOpenIf.FileName,nThenPictureLPi
12、cture=LoadPicture(TileName)EndIfEndWithSetoDLG=NothingEndSubPrivateSubCommand5_Click()DimScaleModeAsIntegerScaleMode=Picture1.scaleModePicture1.scaleMode=3PrintenscaleMode=6PrinteEPaintPicturePicturelJmage,O,O,PicturekScaleWidth,PictureLScaIeHeight,O,O,PictureLScaleWidth,PictureLScaleHeightPrintenEndDocPicture1.ScaleMode=ScaleModeEndSubPrivateSubCommand6-Click()PictureLClsPicture1.AutoRedraw=TrueSetPictureLPicture=LoadPiCtUre()BSString=,n,EndSub四、程序运行结果0Form条码数据生成条码打印打开保存3150331040五、设计心得体会通过这次实验让我更加熟悉了条形码的生成过程,在设计过程中虽然有许多困难,而且39码与25码之间有很多不一样的地方,通过仔细研究,我更加了解了他们之间的区别,为我设计不一样的条码奠定了基础。