PCDVD數位科技討論區

PCDVD數位科技討論區 (https://www.pcdvd.com.tw/index.php)
-   疑難雜症區 (https://www.pcdvd.com.tw/forumdisplay.php?f=34)
-   -   excel VBA的問題﹕如何批次更改物件的屬性? (https://www.pcdvd.com.tw/showthread.php?t=794163)

hagger 2008-05-15 02:35 PM

excel VBA的問題﹕如何批次更改物件的屬性?
 
如果有一群"序列性名稱"控制項

如﹕TextBox1、TextBox2、TextBox3……TextBox50

要同時更改它們的屬性,例如﹕

TextBox1.Visable=false
TextBox2.Visable=false
TextBox3.Visable=false
.
.
.
TextBox50.Visable=false

如何透過迴圈來達成,像底下這樣嗎?

for i=1 to 50
?????.Visable=false '←不知如何以變數來表達物件名稱
next

小弟是VBA的新手,請不吝賜教,謝謝﹗

ICLA 2008-05-18 10:03 PM

不知道有沒有集合名稱可以用,但我是這樣做的,參考看看吧:

For i = 0 To Me.Controls.Count - 1

If InStr(1, Me.Controls.Item(i).Name, "TextBox") > 0 Then

Me.Controls.Item(i).Visible = False

End If

Next


所有的時間均為GMT +8。 現在的時間是08:15 PM.

vBulletin Version 3.0.1
powered_by_vbulletin 2025。