VB.NET中的循环(每次) [英] Loopings In VB.NET (FOR EACH)

查看:50
本文介绍了VB.NET中的循环(每次)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在vb.net中编写程序.它里面有很多文本框.我如何清除每个循环使用它们.

I am currently making a program in vb.net. it has lots of Text box inside of it. how do i clear them using for each loop.

我在这里有我的代码,但是程序没有任何反应,我的文本框仍然有数据.

I have here my code but nothing happens in my program, my text boxes still have data.

For Each txt As TextBox In personalInfo.Controls
            txt.Enabled = False
Next

顺便说一下,我有三个带有文本框的分组框,如何用此代码清除所有文本框.

by the way i have three group boxes with text boxes how do i clear all of text boxes with this code.

推荐答案

使用

txt.Clear();

用于清除文本框.您确定personalInfo中的所有控件都是TextBoxes吗?如果没有,请使用

for clearing a TextBox. Are you sure that all controls in personalInfo are TextBoxes? If not, use

For Each txt In personalInfo.Controls
   If TypeOf (txt) Is TextBox Then
      txt.Clear()
   End If
Next

这篇关于VB.NET中的循环(每次)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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