<tfoot id='nyM7B'></tfoot>
    1. <i id='nyM7B'><tr id='nyM7B'><dt id='nyM7B'><q id='nyM7B'><span id='nyM7B'><b id='nyM7B'><form id='nyM7B'><ins id='nyM7B'></ins><ul id='nyM7B'></ul><sub id='nyM7B'></sub></form><legend id='nyM7B'></legend><bdo id='nyM7B'><pre id='nyM7B'><center id='nyM7B'></center></pre></bdo></b><th id='nyM7B'></th></span></q></dt></tr></i><div id='nyM7B'><tfoot id='nyM7B'></tfoot><dl id='nyM7B'><fieldset id='nyM7B'></fieldset></dl></div>
        <bdo id='nyM7B'></bdo><ul id='nyM7B'></ul>
    2. <small id='nyM7B'></small><noframes id='nyM7B'>

      <legend id='nyM7B'><style id='nyM7B'><dir id='nyM7B'><q id='nyM7B'></q></dir></style></legend>

      1. 在 VB.NET 中检查空的 TextBox 控件

        Check for empty TextBox controls in VB.NET(在 VB.NET 中检查空的 TextBox 控件)
          <tfoot id='HhnRv'></tfoot>
            <tbody id='HhnRv'></tbody>

          <legend id='HhnRv'><style id='HhnRv'><dir id='HhnRv'><q id='HhnRv'></q></dir></style></legend>
            <bdo id='HhnRv'></bdo><ul id='HhnRv'></ul>

              <small id='HhnRv'></small><noframes id='HhnRv'>

                  <i id='HhnRv'><tr id='HhnRv'><dt id='HhnRv'><q id='HhnRv'><span id='HhnRv'><b id='HhnRv'><form id='HhnRv'><ins id='HhnRv'></ins><ul id='HhnRv'></ul><sub id='HhnRv'></sub></form><legend id='HhnRv'></legend><bdo id='HhnRv'><pre id='HhnRv'><center id='HhnRv'></center></pre></bdo></b><th id='HhnRv'></th></span></q></dt></tr></i><div id='HhnRv'><tfoot id='HhnRv'></tfoot><dl id='HhnRv'><fieldset id='HhnRv'></fieldset></dl></div>
                  本文介绍了在 VB.NET 中检查空的 TextBox 控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 VB.NET 中有一个 Form 应用程序.

                  Ive got a Form application in VB.NET.

                  我在一个表单上有很多文本框(大约 20 个).无论如何要一次检查它们是否为空,而不是写出大量代码来单独检查每个,例如

                  I have many text boxes on one form (about 20). Is there anyway to check them all at once to see if they are empty instead of writing out a massive line of code to check each one individually such as

                  If txt1.text = "" Or txt2.text="" Then
                      msgbox("Please fill in all boxes")
                  

                  这似乎还有很长的路要走?

                  That just seems like a long way around it?

                  推荐答案

                  你也可以使用 LINQ:

                  You could also use LINQ:

                  Dim empty =
                      Me.Controls.OfType(Of TextBox)().Where(Function(txt) txt.Text.Length = 0)
                  If empty.Any Then
                      MessageBox.Show(String.Format("Please fill following textboxes: {0}",
                                      String.Join(",", empty.Select(Function(txt) txt.Name))))
                  End If
                  

                  有趣的方法是Enumerable.OfType

                  查询语法相同(在 VB.NET 中更易读):

                  The same in query syntax(more readable in VB.NET):

                  Dim emptyTextBoxes =
                      From txt In Me.Controls.OfType(Of TextBox)()
                      Where txt.Text.Length = 0
                      Select txt.Name
                  If emptyTextBoxes.Any Then
                      MessageBox.Show(String.Format("Please fill following textboxes: {0}",
                                      String.Join(",", emptyTextBoxes)))
                  End If
                  

                  这篇关于在 VB.NET 中检查空的 TextBox 控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to keep the Text of a Read only TextBox after PostBack()?(PostBack()之后如何保留只读文本框的文本?)
                  Winforms Textbox - Using Ctrl-Backspace to Delete Whole Word(Winforms 文本框 - 使用 Ctrl-Backspace 删除整个单词)
                  C# - Add button click events using code(C# - 使用代码添加按钮单击事件)
                  Multi-color TextBox C#(多色文本框 C#)
                  C# Numeric Only TextBox Control(C# 纯数字文本框控件)
                  C# .NET multiline TextBox with same-width characters(具有相同宽度字符的 C# .NET 多行文本框)
                  <legend id='A2RSK'><style id='A2RSK'><dir id='A2RSK'><q id='A2RSK'></q></dir></style></legend>

                    <tfoot id='A2RSK'></tfoot>

                        <tbody id='A2RSK'></tbody>

                          <bdo id='A2RSK'></bdo><ul id='A2RSK'></ul>
                          <i id='A2RSK'><tr id='A2RSK'><dt id='A2RSK'><q id='A2RSK'><span id='A2RSK'><b id='A2RSK'><form id='A2RSK'><ins id='A2RSK'></ins><ul id='A2RSK'></ul><sub id='A2RSK'></sub></form><legend id='A2RSK'></legend><bdo id='A2RSK'><pre id='A2RSK'><center id='A2RSK'></center></pre></bdo></b><th id='A2RSK'></th></span></q></dt></tr></i><div id='A2RSK'><tfoot id='A2RSK'></tfoot><dl id='A2RSK'><fieldset id='A2RSK'></fieldset></dl></div>
                        • <small id='A2RSK'></small><noframes id='A2RSK'>