Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim emptyCount As Integer = Controls.OfType(Of TextBox)().Count(Function(t) t.TextLength = 0) MsgBox(emptyCount & "個空白です") End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim emptyCount As Integer = 0 Dim nonValueCount As Integer = 0 Dim minusCount As Integer = 0 Dim d As Double For Each txt In Me.Controls.OfType(Of TextBox)() If txt.TextLength = 0 Then emptyCount += 1 ElseIf Not Double.TryParse(txt.Text, d) Then nonValueCount += 1 ElseIf d < 0.0 Then minusCount += 1 End If Next MsgBox("空白=" & emptyCount & "/非数値=" & nonValueCount & "/負数=" & minusCount) End Sub