在INI文件中读取逗号分隔的整数

时间:2014-02-19 07:20:49

标签: vba excel-vba vbscript excel

我有一个看起来像这样的INI文件!

[columnNumber]
Number1=2,4

这是我的代码 ini文件是read using function defined here

将columberNumber视为字符串“2,4”我想将其拆分并将其传递给我的选择案例对象mytmp循环以获取Number1中的所有值将其传递给选择中的mytmp

columnNum = ReadIni(file, "columnNumber", "Number1")
    mytmp = columnNum
    x = Split(mytmp, ",")
    For k = 0 To UBound(x)
    'mytmp1 = Split(array_colnum, ",")
    'mytmp2 = Search(array_col)


    'mytmp1 = x(k)
    'mytmp2 = x(k)
    Next k

这是我的选择案例

select case i...<does something>

       select case mytmp 

有人可以指导我这样做吗!

更新:我想在select case i中输入从[columnNumber]得到的值我的ReadIni函数从[columnNumber section]读取number1 = {2,4}我想将其拆分并存储在变量中,从select case variable

中读取变量

1 个答案:

答案 0 :(得分:3)

并不完全清楚你究竟想做什么...... 什么是&#34;我&#34;变量?它应包含什么?

    mytmp = "2,4"
    x = Split(mytmp, ",")

    For k = LBound (x) To UBound (x)
            '## Get value and store in variable "I".
            i = x (k) 

            Select Case i
                    Case "2"
                            Response.Write "yep, it's 2"
                    Case "4"
                            Response.Write "yep, it's 4"
            End Select
    Next