文章正文

VB+MapX中读取.ini的初始化文件

文章来源: 文章作者: 2006-12-11  字体:[ 我要投稿!

eg:比如要读取 d:\haha\a.ini里面的 [options]节点下的FileName就这样写:

字串4

strA=GetProfile("d:\haha\a.ini","options","FileName") 字串9

定义GetProfile函数

字串2

Function   GetProfile(strFileName   As   String,   strSection   As   String,   strName   As   String)   As   String 字串4

strSectionTemp   =   ""  
strNameTemp   =   ""   
strreturn   =   ""  
On   Error   GoTo   ErrReadFile  
Open   strFileName   For   Input   As   #1

字串2

'查询节点 字串9

 Do   While   Not   EOF(1)  
                  strCharA   =   Input(1,   #1)  
                  If   strCharA   =   "["   Then  
                        Do   While   Not   EOF(1)  
                            strCharB   =   Input(1,   #1)  
                            If   strCharB   =   "]"   Then   Exit   Do  

字串9

                            strSectionTemp   =   strSectionTemp   &   strCharB  
                        Loop  
                  End   If  
                  If   strSectionTemp   =   strSection   Then  
                      strCharA   =   Input(2,   #1)  
                      Exit   Do  

字串2


                  Else  
                      strSectionTemp   =   ""  
                  End   If  
            Loop  
    On   Error   GoTo   ErrSrchSection

字串1

 定义标签 字串5

aa: 字串8

strNameTemp   =   ""  
          Do   While   Not   EOF(1)  
              strCharA   =   Input(1,   #1)  
              If   strCharA   <>   "="   Then  
                  strNameTemp   =   strNameTemp   &   strCharA     'gained   name  
              Else  
                  Exit   Do  

字串7


              End   If  
          Loop  
                  If   strNameTemp   =   strName   Then  
                Line   Input   #1,   strreturn  
          Else  
                Line   Input   #1,   strreturn  
                GoTo   aa  
          End   If   字串5
          Close   #1  
          GetProfile   =   strreturn  
          Exit   Function  
  ErrReadFile:  
          Dim   inrRet   As   Integer  
          intret   =   MsgBox("read   'test.ini'   failed!"   &   Chr(10)   &   "a   file   is   missing   or   invalid",   vbAbortRetryIgnore   +   vbExclamation,   "error")  
          Select   Case   intret  
字串7

                Case   vbAbort  
                      GetProfile   =   ""  
                      Close   #1  
                      End  
                      Exit   Function  
                Case   vbRetry  
                      Resume  

字串6


                Case   vbIgnore  
                      Resume   Next  
            End   Select  
  ErrSrchSection:  
            MsgBox   "no   node   in   'ini'   file",   vbOKOnly   +   vbExclamation,   "error"  
            GetProfile   =   ""  
            Close   #1  
            End   字串2
  End   Function 字串7


上一篇:Oracle Spatial 引用支持 (SRID)
下一篇:VB+MapX中读取.ini的初始化文件
收藏本文: Del.icio.us Google书签 Digg Live Bookmark 365Key网摘 天极网摘 和讯网摘 QQ书签 Digbuzz我挖网 该页面添加到 Mister Wong
精彩图片推荐
今日推荐
用户名:新注册) 密码: 匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 最新评论
搜索:
  • 第一视频联播网广告联盟 群视传播文内广告联盟
  • 通过BackLinks卖链接赚美元 注册Text Link Ads 就送25美元
   网站首页 -  关于我们 -  联系我们 -  网站地图 -    RSS订阅 - 网站博客 -  网站投稿 -  链接申请 -  网站留言
Copyright 2007 www.gispark.com All Rights Reserved 闽ICP备06027130号