枚举文本框 [英] Enumerating Textboxes

查看:89
本文介绍了枚举文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想快速检查一组文本框,只是为了看看它们是否包含任何内容。


我试过这段代码但它出现了基于

框创建时间从一个盒子到另一个盒子。


是否可以重置创建时间,以便循环检查从顶部到

底部没有跳过。


Private Sub Command49_Click()

Dim ctl As Control

For Each ctl In Me.Controls

如果ctl.ControlType = acTextBox那么

如果ctl.Tag ="验证数据"然后

如果ctl.Value> ""然后

ctl.Value = ctl.Value

Else

MsgBox缺少数据

ctl.SetFocus

退出

结束如果

结束如果

结束如果

下一步< br $>
结束子


谢谢,瑞克

解决方案

你好Rick,


建议在表单中执行剪切然后粘贴文本框。也许

会以自上而下的顺序重置文本框的创建时间。


HTH。琳达


" 2D Rick" < RB ******* @ compuserve.com>在消息中写道

news:11 ********************** @ g43g2000cwa.googlegr oups.com ...

我想快速检查一组文本框,只是为了看看它们是否包含任何内容。

我试过这段代码,但它似乎是从一个盒子到另一个盒子在
框创建时间。

是否可以重置创建时间,以便循环从顶部检查到底部而不会跳过。

Private Sub Command49_Click()
Dim ctl As Control
For Metl in Me.Controls
如果ctl.ControlType = acTextBox那么
如果ctl.Tag =验证数据然后
如果ctl.Value> ""然后
ctl.Value = ctl.Value
其他
MsgBox缺少数据
ctl.SetFocus
退出
结束如果
结束如果
结束如果
下一页
结束子

谢谢,Rick



订购如果我在同一个表格中剪切和粘贴并粘贴

到新表格中保持不变。


感谢您的回复

RICK


2D Rick在留言中写道

< 11 *************** *******@g43g2000cwa.googlegroups .com> :

我想快速检查一组文本框,只是为了看看它们是否包含任何内容。

我试过这段代码,但它似乎已经去了从盒子到盒子根据盒子的创建时间。

是否可以重置创建时间,以便循环从顶部检查到底部而不会跳过。

Private Sub Command49_Click()
Dim ctl As Control
For Each ctl In Me.Controls
如果ctl.ControlType = acTextBox那么
如果ctl.Tag =" ;验证数据然后
如果ctl.Value> ""然后
ctl.Value = ctl.Value
其他
MsgBox缺少数据
ctl.SetFocus
退出
结束如果
结束如果
结束如果
下一页

谢谢,瑞克




我认为有不久前在这个NG中的一个帖子讨论了

这个。如果我没弄错的话,我认为答案是否定的(至少实际上是b $ b),认为收藏品是无序的。


这里'一个建议

- 在盒子上使用命名约定使它成为可能将它们作为控制数组循环,即

txt1,txt2,txt3 ..

for lngcounter = 1 to N

msgbox me.controls(" txt"& cstr (lngcounter))。价值

next lngcounter


-

Roy-Vidar


I want to do a quick check of a group of textboxes only to see if they
contain anything.

I tried this code but it appears to go from box to box based on the
boxes time of creation.

Is it possible to reset creation time so the loop checks from top to
bottom without skipping around.

Private Sub Command49_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "Verify Data" Then
If ctl.Value > "" Then
ctl.Value = ctl.Value
Else
MsgBox "Missing Data"
ctl.SetFocus
Exit For
End If
End If
End If
Next
End Sub

Thanks, Rick

解决方案

Hi Rick,

Suggest doing a Cut and then Paste of the textboxes in your form. Perhaps
that will reset the
creation time of the textboxes in top to bottom order.

HTH. Linda

"2D Rick" <rb*******@compuserve.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

I want to do a quick check of a group of textboxes only to see if they
contain anything.

I tried this code but it appears to go from box to box based on the
boxes time of creation.

Is it possible to reset creation time so the loop checks from top to
bottom without skipping around.

Private Sub Command49_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "Verify Data" Then
If ctl.Value > "" Then
ctl.Value = ctl.Value
Else
MsgBox "Missing Data"
ctl.SetFocus
Exit For
End If
End If
End If
Next
End Sub

Thanks, Rick



Order stayed the same if I Cut and Pasted within same form and pasting
into new form.

Thanks for the reply
RICK


2D Rick wrote in message
<11**********************@g43g2000cwa.googlegroups .com> :

I want to do a quick check of a group of textboxes only to see if they
contain anything.

I tried this code but it appears to go from box to box based on the
boxes time of creation.

Is it possible to reset creation time so the loop checks from top to
bottom without skipping around.

Private Sub Command49_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Tag = "Verify Data" Then
If ctl.Value > "" Then
ctl.Value = ctl.Value
Else
MsgBox "Missing Data"
ctl.SetFocus
Exit For
End If
End If
End If
Next
End Sub

Thanks, Rick



I think there was a thread in this NG not long ago discussing
this. If I''m not mistaken, I think the answer was no (at least
for practical purposes), think of collections as unordered.

Here''s one suggestion
- use a naming convention on the boxes that makes it
possible to loop them as "control array", i e

txt1, txt2, txt3..

for lngcounter = 1 to N
msgbox me.controls("txt" & cstr(lngcounter)).value
next lngcounter

--
Roy-Vidar


这篇关于枚举文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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