tips_7 面向VisualBasic程序员的杂志 第7版.docx
《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
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- tips_7 面向VisualBasic程序员的杂志 第7版 面向 VisualBasic 程序员 杂志