The objects I am trying to mass select are text boxes, and I am trying to select them all, without tediously selecting all of them, to see if any are blank and place in a 0 if any are.
Is there a way to do that?
4 Replies - 200 Views - Last Post: 19 March 2012 - 05:49 AM
#1
Question: Is it possible to "mass select" several unconnected
Posted 19 March 2012 - 04:37 AM
Replies To: Question: Is it possible to "mass select" several unconnected
#2
Re: Question: Is it possible to "mass select" several unconnected
Posted 19 March 2012 - 04:55 AM
are you developing an application or website ?
There are numerous ways of doing that .
Well , an easy way that i prefer is to iterate through all controls on the form
There are numerous ways of doing that .
Well , an easy way that i prefer is to iterate through all controls on the form
Dim cCtrl As Control
For Each cCtrl in Form1.Controls
If (TypeOf cCtrl Is TextBox) Then
If cCtrl.Text = "" then
cCtrl.Text = "0"
End If
End If
Next
This post has been edited by shadachi: 19 March 2012 - 05:07 AM
#3
Re: Question: Is it possible to "mass select" several unconnected
Posted 19 March 2012 - 04:59 AM
if you want to see if any of textbox is blank you can check like this
if you want to select whole text in textbox you do it like this:
if you want to do this programmatically for a lots of textboxes than put all textboxes to List Of textboxes. Than you can loop through list and do what you want.
If textbox1.text="" then ...
if you want to select whole text in textbox you do it like this:
textBox1.Selectionstart = 1 textBox1.SelectionLength = textBox1.Text.ToString().Length textBox1.Focus()
if you want to do this programmatically for a lots of textboxes than put all textboxes to List Of textboxes. Than you can loop through list and do what you want.
Public Class Form1
Private txtBoxes As New List(Of TextBox)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtBoxes.Add(TextBox1)
txtBoxes.Add(TextBox2)
txtBoxes.Add(TextBox3)
For Each txtBox As TextBox In txtBoxes
If txtBox.Text = "" Then txtBox.Text = 0
Next
End Sub
End Class
#4
Re: Question: Is it possible to "mass select" several unconnected
Posted 19 March 2012 - 05:07 AM
#5
Re: Question: Is it possible to "mass select" several unconnected
Posted 19 March 2012 - 05:49 AM
Apologies for the double post. No edit button...
Apart from having to add "Me." to cControl, it works perfectly. Thank you.
Apart from having to add "Me." to cControl, it works perfectly. Thank you.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|