《《条码技术》课程设计--Code25码生成与识别程序设计.docx》由会员分享,可在线阅读,更多相关《《条码技术》课程设计--Code25码生成与识别程序设计.docx(10页珍藏版)》请在第一文库网上搜索。
1、条码技术课程设计题目Code25码生成与识SU一、课程设计目标3二、程序界面设计3三、程序代码设计4四、程序运行结果9五、设计心得体会10一、程序设计目标任选一种条码码制(39码除外),编程实现条码的生成、打印、存储、打开、识别等功能。(利用Core1Draw软件生成不同码制的条形码符号。熟悉VB编程环境下的一些基本操作和基本编程语言。利用VB编写程序实现条码的生成。利用VB编写程序实现条码的识别。)二、程序界面设计nForm1生成条码打开程序界面设计应该包括绘图、条码编译、打开图片、保存图片、打印、清空等基本内容。三、程序代码设计程序代码的内容:OptionExp1icitPrivateCh
2、arStringAsStringPrivatest(OTo9)AsStringPrivateCheckStringAsStringDimbarTextAsStringDimMaxX,MaxYAsIntegerDimStartX,StartXEndX,EndYAsIntegerDimBSStringAsStringDimDataStringAsStringDimFi1eNameAsIntegerPrivateSubformOad()CharString=0123456789st(O)=00110,0st(1)=1000,1st(2)=0100,h2st(3)=hIIOOOhh3st(4)=h00
3、10,h4st(5)=h10100h5st(6)=h01100,6st(7)=0001,7st(8)=100108st(9)=010109Fi1eName=1EndSubPrivateSubCommand1_C1ick()barText=Text1TextPicture1C1sDims,eAsInteger”起始符与终止符Dimi,j,K,c,x,yAsIntegerMaxX=0MaxY=0x=40yO=3O起始符Fors=1To3Picture11ine(x,y)-(x,y+100*HScro111.Va1ue)x=x+1Nextsx=x+1Fors=1To3Picture11ine(x,y
4、)-(x,y+IOO*HScro111.Va1ue)x=x+1Nextsx=x+1Picture11ine(x,y)-(x,y+IOO*HScro111.Va1ue)x=x+2条码DimCtr1StringAsStringForK=1To1en(barText)Ctr1String=st(InStr(1,n0123456789,Mid(barText,K,1)-1)Fori=1To5c=Int(Mid(Ctr1String,i,1)IfC=IThen”画宽条Forj=1To3*HScro11!.Va1uePicture11ine(x,y)-(x,y+IOO*HScro111.Va1ue)x=x
5、+1NextjE1sePicture11ine(x,y)-(x,y+IOO*HSCro11I.Va1ue)”画窄条x=x+1EndIfXo=Xo+1,画空NextiNextK”终止符Fors=1To3Picture11ine(x,y)-(x,y+IOO*HScro111.Va1ue)x=x+1Nextsx=x+1Picture11ine(x,y)-(x,y+IOO*HScro111.Va1ue)x=x+2Fors=1To3Picture11ine(x,y)-(x,y+IOO*HScro111.Va1ue)x=x+1Nextsx=x+1MaxX=Picture1CurrentX+30MaxY=P
6、icture1CurrentY+30EndSubPrivateSubpicture1_MouseDown(buttonAsInteger,shiftAsInteger,XAsSing1e,yAsSing1e)StartX=xStartY=yBSString=nEndSubPrivateSubpicture1_MouseMove(buttonAsInteger,shiftAsInteger,xAsSing1e,yAsSing1e)Ifbutton=1ThenPicture11ine(StartX,StartY)-(x,StartY),vbRedPicture11ine(StartX,StartY
7、+1)-(x,StartY+1),vbRedPicture11ine(StartX,StartY+2)-(x,StartY+2),vbRedEndIfEndSubPrivateSubCommand4_C1ick()DimCommonDia1og1SetCommonDia1og1=CreateObject(nMSComD1g.CommonDia1og,)CommonDia1og1.Fi1eName=nnCommonDia1og1Fi1ter=nJPG图片(*JPG)*.jpgBMP图片(*.BMP)*上mpICO图标(*.ICO)I*.icoGIF图片(*.GIF)*.giFCommonDia1
8、og1ShowSaveIfCommonDia1og1.Fi1eNameThenSavePicturePicture1Image,CommonDia1og1Fi1eNameEndSubPrivateSubpicture1_MouseUp(buttonAsInteger,shiftAsInteger,xAsSing1e,yAsSing1e)EndX=xEndY=yBSString=nnDimiAsIntegerDimco1AsCo1orConstantsFori=StartXToEndXco1=Picture1.Point(i,StartY-1)Ifco110ThenBSString=BSStri
9、ng&0E1seBSString=BSString&1EndIfNextCommand2_C1ickEndSubPrivateSubCommand2_C1ick()DimStempAsStringDimc,i,j,KAsIntegerDimtemp(0To4)AsStringBSString=Mid(BSString,InStr(1,BSString,1),1en(BSString)去前空白区OFori=1en(BSString)To1Step去后空白区OIfMid(BSString,i,1)OThenBSString=Mid(BSString,1,i+1)ExitForEndIfNextK=
10、Oc=0Forj=11To1en(BSString)-10IfMid(BSString,j,1)=OAndc3Thentemp(K)=OK=K+1c=0E1seIfMid(BSString,j,1)=OAndc=3Thentemp(K)=1K=K+1c=0E1seIfMid(BSString,j,1)=1Andc3Thenc=c+1EndIfIfK=5ThenK=OStemp=nStemp=temp(0)&temp(1)&temp(2)&temp(3)&temp(4)Fori=0To9Ifst(i)=StempThenDataString=DataString&Mid(CharString,i
11、+1,1)EndIfNextiEndIfNextjMsgBox条码符号表示的信息为:&vbCr1f&DataStringDataString=nEndSubPrivateSubCommand3_C1ick()Picture1C1sDimoD1GSetoD1G=CreateObject(MSComD1g.CommonDia1og,)WithoD1G.Dia1ogTit1e=打开文件”.Fi1ter=图片文件|*.jpg;*.bmp;*.tif.Fi1terindex=1.MaxFi1eSize=255.ShowOpenIf.Fi1eNamenThenPicture1Picture=1oadPic
12、ture(.Fi1eName)EndIfEndWithSetoD1G=NothingEndSubPrivateSubCommand5_C1ick()DimSca1eModeAsIntegerSca1eMode=Picture1sca1eModePicture1.Sca1eMode=3Printer.Sca1eMode=6PrinteEPaintPicturePicture1Image,O,O,Picture1Sca1eWidth,Picture1Sca1eHeight,O,O,Picture1Sca1eWidth,Picture1Sca1eHeightPrinterEndDocPicture1.Sca1eMode=Sca1eModeEndSubPrivateSubCommand6_C1ick()Picture1C1sPicture1AutoRedraw=TrueSetPicture1Picture=1oadPicture(nn)BSString=nEndSub四、程序运行结果0Form1生成条码打开编译打印保存条码数据3150331040五、设计心得体会通过这次实验让我更加熟悉了条形码的生成过程,在设计过程中虽然有许多困难,而且39码与25码之间有很多不一样的地方,通过仔细研究,我更加了解了他们之间的区别,为我设计不一样的条码奠定了基础。