定义一个带有变量的命令按钮的名称 [英] define a name of a commandbutton with a variable in it

查看:67
本文介绍了定义一个带有变量的命令按钮的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在userform中设置commandbutton的属性,而不是通过键入'commandbutton1'来定义它的名称,而是输入'commandbutton + number'作为名称,数字= 1,使用它就像我应该能够为数字
= 1到10 ...下一个循环并设置属性到每个命令按钮,名称为commandbutton1,commandbutton2,...,commandbutton10。

I would like to know how I can set properties of a commandbutton in a userform with defining it's name not by typing 'commandbutton1' but by typing 'commandbutton + number' as name with number = 1, using it like that i should be able to make a for number = 1 to 10 ... next loop and set properties to each commandbutton with the name commandbutton1, commandbutton2, ..., commandbutton10.




推荐答案

喜欢这样:

Dim i As Integer

For i = 1 to 10

Me.Controls(" CommandButton"& i).Caption ="我是按钮#" &安培;我是
接下来我

Dim i As Integer
For i = 1 To 10
Me.Controls("CommandButton" & i).Caption = "I'm Button #" & i
Next i


这篇关于定义一个带有变量的命令按钮的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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