vb读写文件(vb read and write files)

vb读写文件(vb read and write files)

ID:9297033

大小:20.10 KB

页数:11页

时间:2018-04-27

vb读写文件(vb read and write files)_第1页
vb读写文件(vb read and write files)_第2页
vb读写文件(vb read and write files)_第3页
vb读写文件(vb read and write files)_第4页
vb读写文件(vb read and write files)_第5页
资源描述:

《vb读写文件(vb read and write files)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、vb读写文件(VBreadandwritefiles)VBreadandwritefilestousethefollowingstatement:1,Openstatementopensthefile.2,readInput,InputfilesusingLine#,(abovetext)andGet(abovebinarymode).3,writefilesusingPrint#,Write(abovetext)andPut(abovebinarymode).4,Closestatementclosesfile5,binarymodemobilefilelocationusi

2、ngSeekstatement.AllofthesestatementsareexplainedandillustratedindetailwiththehelpofVB.Examplesoftextfiles:Open"TESTFILE"ForOutputAs#1'openstheoutputfile.Print#1,"Thisisatest",writestextdatatoafile.Print#1,'writesblanklinestofiles.Print#1,"Zone1";Tab;"Zone2"dataiswrittentotwozones(printzones)

3、.Print#1,"Hello";"";"World";twostringsseparatedbyspaces.Print#1,Spc(5);"5leadingspaces".Writefivespacesbeforethestring.Print#1,Tab(10);"Hello".Writedataintenthcolumns.'assigningBoolean,Date,NullandErroretc..DimMyBool,MyDate,MyNull,MyErrorMyBool=False:MyDate=#February12,1969#:MyNull=NullMyErr

4、or=CVErr(32767)'True,False,NullandErrorautomaticallyconvertformatsaccordingtothelocalesettingsofthesystem.'datewillbeshowninthestandardshortdateformat.Print#1,MyBool;"isaBooleanvalue""Print#1,MyDate;"isadate""Print#1,MyNull;"isanullvalue""Print#1,MyError;"isanerrorvalue""Close#1'closefile.Ex

5、ampleofreadingfileUsetheLineInput#statementreadsalinefromasequentialfile,andthedatatoavariable.ThisexampleassumesthattheTESTFILEfilecontainsthenumberoflinesoftextdata.DimTextLineOpen"TESTFILE"ForInputAs#1'opensthefile.DoWhileNotEOF(1)'cycletofiletail.LineInput#1,TextLine'readsarowofdataandgi

6、vesittoavariable.Debug.PrintTextLine'displaysdatainthedebugwindow.LoopClose#1'closefile.Youcanalsofindmanyoftheseproblemsandexamplesinour"disk,fileanddirectory"column.GetandPutstatementscanalsoreadandwritemultiplebytes,andeachreadandwritecontentcanbeplacedinabytevariablearraytoimprovetheprog

7、ramspeed.Forexample:DimDSX()AsByte'isanarrayofbytesusedtostorereadandwritecontentDimReadFileNo,WriteFileNoAsInteger'readwritefilenumber'ConstUnit=100000'readandwriteblocksizeOpenSourceFileNameForBinaryAccessReadAs1WriteFileNo=FreeFileOpenTargetFile

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。