如何使用函数来更改文本框颜色 [英] How to use function to change textbox color
问题描述
我是视觉基础新手6,在形式上我有20个文本框,如
If(texbox1.Text< 2.85)或(textbox1.Text> ; 3.15)然后
textbox1.Text =""
Else
textbox1.BackColor =& H80000011
结束如果
If(texbox2.Text< 2.85)或(textbox2.Text> 3.15)然后
textbox2.Text =""
Else
textbox2.BackColor =& H80000011
结束如果
是否有一种方法可以使用函数来更改背景颜色而不必重复其他20个文本框中的
。顺便说一句,请不要让我为20个文本框创建
控制数组,因为某些原因。
你可以准备您自己的方法。
- 创建一个以文本框控件作为参数的方法。
- 在该方法中编写您在此处完成的操作。
- 将所有文本框控件传递给该方法。
您可以自己准备方法。
- 使用文本框创建方法
- 在该方法中编写您在此处完成的操作。
- 将所有文本框控件传递给该方法。
我不明白,是不是仍然需要为20个文本框编码?
展开 | 选择 | Wrap | 行号跨度>
Hi, I am new to visual basic 6, In a form I have many 20 textboxes such as
If (texbox1.Text < 2.85) Or (textbox1.Text > 3.15) Then
textbox1.Text = ""
Else
textbox1.BackColor = &H80000011
end if
If (texbox2.Text < 2.85) Or (textbox2.Text > 3.15) Then
textbox2.Text = ""
Else
textbox2.BackColor = &H80000011
end if
Is there a way that i can use function to change the backcolor without repeating
for the rest of the 20 textboxes. By the way please dont ask me to create
control array for the 20 text boxes as due to some reasons.解决方案You can prepare your own method.
- Create a method with textbox control as parameter.
- Program what you done here inside that method.
- Pass all the textbox control to that method.
You can prepare your own method.
- Create a method with textbox control as parameter.
- Program what you done here inside that method.
- Pass all the textbox control to that method.
I don;t really understand, Isn''t the same as I still need to code for the 20 text boxes ?
Expand|Select|Wrap|Line Numbers
这篇关于如何使用函数来更改文本框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文