在访问中,如何使用变量来寻址对象? [英] In access, how do I use a variable to address an object?
问题描述
我有几个文本框,其名称末尾有数字。 我想使用循环来使用变量更改文本框颜色。第一个文本框名为Board-1:
IE
Dim TextBoxName As String
Dim Cntr作为整数
Cntr = 1
当Cntr< 5
TextBoxName ="Board-"& Str(Cntr)
TextBoxName.BackColor = Red
  ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; Cntr = cntr + 1
WEnd
此语句给出了语法错误:
TextBoxName.BackColor = Red
你知道怎么做吗?
您好,
没有构建常量"红色",但您可以使用vbRed。
如果你想使用自己的变量 - 你需要将变量声明为Long:Dim myColor as Long
Nadia
I have several text boxes with names that have numbers on the end. I want to use a loop to change the text box color using a variable. The first text box is named Board-1:
I.E.
Dim TextBoxName As String
Dim Cntr As Integer
Cntr = 1
While Cntr < 5
TextBoxName = "Board-" & Str(Cntr)
TextBoxName.BackColor = Red
Cntr = cntr + 1
WEnd
This statement gives me a syntax error:
TextBoxName.BackColor = Red
Do you know how to do this?
Hello,
There is no build in constant "Red", but you can use vbRed.
If you want to use your own variable - you need to declare the variable as Long: Dim myColor as Long
Nadia
这篇关于在访问中,如何使用变量来寻址对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!