tips_7 面向VisualBasic程序员的杂志 第7版.docx

上传人:王** 文档编号:1347663 上传时间:2024-06-21 格式:DOCX 页数:41 大小:130.18KB
下载 相关 举报
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第1页
第1页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第2页
第2页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第3页
第3页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第4页
第4页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第5页
第5页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第6页
第6页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第7页
第7页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第8页
第8页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第9页
第9页 / 共41页
tips_7 面向VisualBasic程序员的杂志 第7版.docx_第10页
第10页 / 共41页
亲,该文档总共41页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《tips_7 面向VisualBasic程序员的杂志 第7版.docx》由会员分享,可在线阅读,更多相关《tips_7 面向VisualBasic程序员的杂志 第7版.docx(41页珍藏版)》请在优知文库上搜索。

1、WelcometotheSeventhEditionoftheVBPJTechnicalTipsSupplement!VB3,VB416/32,VB51.evel:BeginningDeletinganArrayElementConventionalwisdomsuggeststhattodeleteanarrayelement,youmustmoveupallthesubsequentelementstoclosethegapleftbythedeleteditem.However,ifthesequenceoftheelementsisntsignificant(asinanunsorte

2、darray),thisalgorithmquicklydeletesanitem:,Elementtodelete(Delete=5NumberofelementsbeforedeletionnElements三UBound(Array)ReplaceiDeletewithlastiteminarrayArray(IDeIete)=Array(nElements)*UseReDimPreservetoshrinkarraybyoneReDimPreserveArray(1.Bound(Array)_TonElements-1)一BasilHubbard,Hammon,Omario,Canad

3、aVB432,VB5,VBA1.evel:IntermediateInvokehOpenWith.,DialogBoxWhenlaunchingadatafilewiththeSheIIExecuteOfunction,Windowstriestofindtheassociatedapplicationandopenthedatafilewiththisapplication.Butwhathappensifnoassociationexists?SheIIExecuteOsimplyreturnserrorde31(noassociation)andnothinghappens.Wouldn

4、titbeniceifyourprograminvokedthe41Openwith.dialogboxsoyoucanchsewhichapplicationyouwanttoassociatewithyourdatafile?Heresasolution-calltheSheIIDocroutineandpassafullyqualifiedpath/filenameofthedatafileyouwishtoopen:OptionExplicitDeclareFunctionGetDesktopWindow1.ib,tuser32,()As1.ongDeclareFunctionSheI

5、IExecute1.ib_,shell32.drAliasSheIIExecuteA.(ByVaIhW11dAs1.ong,ByVaIIpOperation_AsString,ByVaIIpFiIeAsString,_ByVaIIpParametersAsString,_ByVaIIpDirectoryAsString,_ByVaInShowCmdAs1.ong)As1.ongDeclareFunctionGetSystemDIrectoryUb_“kemel32AliasGetSystemDirectoryA_(ByVaIIpBufferAsString,ByVaInSize_As1.ong

6、)As1.ongPrivateConstSE-ERR-NOASSOC=31PublicSubShellDoc(strFileAsString)DimIngRetAs1.ongDimStrDirAsStringIngRet=SheHEXeCUte(GetDeSktoPWindOw,_open”,StrFiIe,_VbNuIIString1VbNuIIString.VbNormaIFocus)IfIngRet=SE_ERR_NOASSOCThennoassociationexistsStrDir三Space(260)IngRet=GetSyStemDireCtOry(StrDir,_1.en(St

7、rDIr)StrDir三1.eft(strDir,IngRet)showtheOpenwithdialogboxCallShellExecutefGetDesktopWindow,_VbNuIIString,RUND1.1.32.EXE-,Mshell32.dll,OpenAs.RunD1.1.”&_StrFite1StrDir1VbNormaIFocus)EndIfEndSub-ThomaSWeidmannjeceivedbyemailVB432,VB51.evel:BeginningSSTABVs.OptionButtonsAlthoughVB,sSSTabntrolbehavesasif

8、eachtabpageisacontainer,itactuallyusesasinglecontainerforalltabpages.Thiscancauseunexpectedbehaviorifyouhavegroupsofoptionbuttonsondifferentpages.Clickingonanoptionbuttonononepageclearsalltheuncontainedoptionbuttonsontheother,seeminglyunrelated,pages.Solvethisproblembyaddingyourowncontainersframesor

9、pictureboxes)foreachgroupofoptionsyouwanttobemutuallyexclusive.SteveCiSCoandROIandSOUtharaFranklin,TenneSSeeVB432,VB51.evel:BeginningChangetheAppearancePropertyofaTextBoxatRunTimeSorry,youcantchangetheAppearancepropertyofatextboxatruntimebutyoucanmakeitlooklikeyouhave!Ifsettonone,a3-Dpictureboxhasaf

10、latBorderStyIeproperty.Putyourtextbox(withaflatappearance)insideapicturebox(witha3-Dappearance)andchangethepictureboxsborderstyle.UsethiscompletecodebesureyouplaceText1insidePicturel:Privatem_TextVAppearanceAs1.ongPrivateSubForm_1.oad()WithText1Picturel.Width=.WidthPicturel-Height三.Height.MoveO,OEnd

11、WithText1_Appearance1,3DEndSubPublicProperty1.et_Text1_Appearance(nAppearanceAs1.ong)WithPicturelSelectCasenAppearanceCaseOFlat.BorderStyIe三nAppearanceCase1,3D.BorderStyIe=nAppearanceEndSelectm_Text1_Appearance三.BorderStyIeEndWitfCEndPropertyPublicPropertyGetText1_AppearanceOAs1.ongTeXt1.APPearanCe三

12、m_Text1_AppearanceEndPropertyJimDeutch,CaZenOvia,NeWYorkVB432,VB51.evel:BeginningDealingWithNullValuesReturnedFromRDOResultsetsIfyou,rassigningthevaluesoflumnsyoureturnfromRDOqueriesintostringvariables,you,llgetanInvaliduseofNulerrorifoneofthecolumnshasaNullvalue.Formostpurposes,dratherhavethevaluea

13、sanemptystringanyway.RatherthancodeforthateachtimeIaccessacolumn,l,vewrittenafunctioncalledCleanthatturnsNullvaluesintoemptystrings.Icallitlikethis:strMyString=Clean(rdoResultset(MMyVarCharColumnM)IalsoconvertEmptyvaluesaswell,forusewithVariants:PublicFunctionClean(ByValvarDataAsVariant)AsStringIfIs

14、NuII(VarData)ThenClean三ElselfIsEmpty(VarData)ThenClean=ElseClean=CStr(VarData)EndlfEndFunction-JameST.Stanley,MuncieJndianaVB3,VB416/32,VB51.evel:BeginningInSearchofSampleCodemalwayslookingforsamplecode,andthesetup1.vbpfileisanexcellentsourceofreusablecode.ItcomeswithVBandispartoftheVBsetupkit.Theco

15、ntentsvary,dependingonwhatversionofVByouhave,butyoullfindusefulexamplesineachversion.Forexample,theVB5filesamplecodedoesthesethings: GetstheWindowsdirectory. GetstheWindowsSystemdirectory. Determinesifafileordirectoryexists. DeterminesifyourerunningWinNTorWin95.,Determinesdrivetype. Checksdiskspace. Createsanewpath. ReadsfromanINIfile. Parsesdateandtime. Retrievestheshortpathnameofafilentaininglongfilenames.Plus,awholemoduleworkstologerrorstoanerrorfile.Thisdeiswell-commentedandcaneasilybecutandpastedintoyourproject.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > Java

copyright@ 2008-2023 yzwku网站版权所有

经营许可证编号:宁ICP备2022001189号-2

本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!