配置文件:

 源码:

Dim Co As Object '设为全局变量
Function 读取cfg() As Boolean
Dim strcfg As String
strcfg = "D:\a.cfg" If Dir(strcfg, vbDirectory) = "" Then
MsgBox "错误:配置文件不存在!" & Chr(10) & strcfg 'Chr(10)换行符
Exit Function
End If Set Co = CreateObject("Scripting.Dictionary")
Dim a As Variant
Dim s As String
Open strcfg For Input As #1
While Not EOF(1)
Line Input #1, s
If Len(s) > 2 Then
If Not InStr(s, "##") Then
If InStr(s, "=") Then
a = Split(s, "=")
Co.Add a(0), a(1)
''Debug.Print a(0) & "=" & a(1)
End If
End If
End If
Wend
Close #1
End Function

用法:

Sub 显示()
Debug.Print Co("A001")
End Sub

最新文章

  1. Bluemix中国版体验(一)
  2. linux mail 使用外部邮箱地址发邮件
  3. opencv 简单模糊和高斯模糊 cvSmooth
  4. Android studio 快捷添加构造方法以及set与get
  5. python模块调用
  6. 【Android】Android之Action Bar
  7. linux - 创建用户
  8. Partition List ——LeetCode
  9. Bootstrap表格的使用
  10. BroadcastReceiver总结
  11. Cocos2d-x源代码解析(1)——地图模块(3)
  12. Revenge of GCD HDU5019
  13. vs设计界面出现“建控件时出错 响应在此上下文中不可用”
  14. 安卓服务Service详解
  15. [Ynoi2018]五彩斑斓的世界
  16. springboot-01 helloworld
  17. Windows 10中设置自动登录
  18. python-随机操作(random)
  19. position fixed 居中
  20. Python 逗号的几种作用

热门文章

  1. CTFHub-技能树-Bypass disable_function:LD_PRELOAD
  2. 【JavaScript】Leetcode每日一题-二叉搜索树的范围和
  3. PHP基础-PHP中预定义的超全局数组
  4. 查询某软件所连接的外网IP地址
  5. DWVA--File Inclusion
  6. Windows进程间通讯(IPC)----信号量
  7. Consul 服务的注册和发现
  8. [Java] Hibernate
  9. linux操作系统故障处理-ext4文件系统超级块损坏修复
  10. Linux_交换分区SWAP