返回列表 上一主題 發帖

[發問] 請教: 如何利用迴圈動態產生變數

[發問] 請教: 如何利用迴圈動態產生變數

Dear 大大
我想產生一些array的變數,如下:
dim 收盤value as Variant
dim 外資value as Variant
dim 投信value as Variant
dim 自營value as Variant
dim 融資value as Variant
dim 融券value as Variant
................
dim 收盤price as Variant
dim 外資price as Variant
dim 投信price as Variant
dim 自營price as Variant
dim 融資price as Variant
dim 融券price as Variant
................
因為很多,而且常常只有變數的後半段不一樣(會有變化),但變數前半段名稱都一樣

請問有沒有可能將: 收盤價,外資,投信,自營商,融資,融券..先變成array

Dim MySheets(8) As String
    MySheets(0) = "收盤"
    MySheets(1) = "外資"
    MySheets(2) = "投信"
    MySheets(3) = "自營商"
    MySheets(4) = "融資"
    MySheets(5) = "融券"
    MySheets(6) = "開盤"
    MySheets(7) = "最高"
    MySheets(8) = "最低"

能不能利用迴圈將它們加上後半段的名稱,來宣告變數
如果VB不行C++可以嗎?

感謝!

回復  bugsfamily
我會用2維陣列來處理這樣的問題
Dim value(8,100) as Variant                      ' ...
alexliou 發表於 2012-5-5 10:59



    感謝。

TOP

        靜思自在 : 做好事不能少我一人,做壞事不能多我一人。
返回列表 上一主題