如何为阵列创建动态变量名? [英] How to Create a Dynamic Variable Name for an Array?

查看:152
本文介绍了如何为阵列创建动态变量名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有ComboBox1中的条目。每次用户选择一个条目时,会触发以下内容:

I have "ComboBox1" with entries in it. Every time the user selects an entry, the following is triggered:

Private Sub ComboBox1_Change()
    call populate(ComboBox1.ListIndex)
End Sub

函数populate具有以下内容:

The function "populate" has the following:

Sub populate(index as integer)

    dim arr0, arr1, arr2 ...
        arr0 = Array(...)
        arr1 = Array(...)
        arr2 = Array(...)

    Do While x < Application.CountA("arr" + index)
        ...
    Loop

End Sub

我想让arr+ index 动态,因此它会根据从调用函数接收的索引调用正确的数组。可以这样做吗?

I want to make "arr" + index dynamic so it calls the proper array based on the index recevied from the caller function. Can this be done?

推荐答案

Sub populate(index as integer)

    dim arr(0 to 2)
        arr(0) = Array(...)
        arr(1) = Array(...)
        arr(2) = Array(...)

    Do While x < Application.CountA(arr(index))
        ...
    Loop

End Sub

这篇关于如何为阵列创建动态变量名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆