473,394 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Looping through specific controls on a form

Dear all,
I'm trying to validate if information has been added in to textboxes and
combo boxes.
Private Function CheckValues() As Boolean
'************************************************* *
'***
'*** Function : CheckValues()
'*** Purpose : Check if all values as filled -in
'***
'***
'***
'************************************************* ***
Dim frmMain As New frmMain '*** Instance of the Main form
Dim ctrl As New Control '*** Instance of the systems control object
With frmMain
For Each ctrl In .Controls
If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Then
If ctrl.Text = "" Then
CheckValues = False
Exit Function
End If
End If
Next
CheckValues = True
End With
End Function

This is what i have so far. But when in the function the ctrl.text property
is empty when in the form there is tekst in the control.
Is this because i am using an instance of the frmmain form ??
If i don't instanciate the frmmain form i can't acces the properties.

Does anyone know an answer on this??

GreetZ,

Eric
Nov 19 '05 #1
2 2166
"Eric.I.Feurich" <e.*******@indocs.nl> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
Dear all,
I'm trying to validate if information has been added in to textboxes and
combo boxes.
Private Function CheckValues() As Boolean
'************************************************* *
'***
'*** Function : CheckValues()
'*** Purpose : Check if all values as filled -in
'***
'***
'***
'************************************************* ***
Dim frmMain As New frmMain '*** Instance of the Main form
Dim ctrl As New Control '*** Instance of the systems control object
With frmMain
For Each ctrl In .Controls
If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Then
If ctrl.Text = "" Then
CheckValues = False
Exit Function
End If
End If
Next
CheckValues = True
End With
End Function

This is what i have so far. But when in the function the ctrl.text property is empty when in the form there is tekst in the control.
Is this because i am using an instance of the frmmain form ??
If i don't instanciate the frmmain form i can't acces the properties.


I cant fully understand what you have written. Perhaps your problem is that
you are getting a value of Nothing from the text property and this is
causing an error. Try this:

If ctrl.Text Is Nothing OrElse ctrl.Text = "" Then
...
End If
HTH,
Jeremy

Nov 19 '05 #2
"Eric.I.Feurich" <e.*******@indocs.nl> schrieb
Dear all,
I'm trying to validate if information has been added in to textboxes
and combo boxes.
Private Function CheckValues() As Boolean
'************************************************* *
'***
'*** Function : CheckValues()
'*** Purpose : Check if all values as filled -in
'***
'***
'***
'************************************************* ***
Dim frmMain As New frmMain '*** Instance of the Main form
Dim ctrl As New Control '*** Instance of the systems control
object With frmMain
For Each ctrl In .Controls
If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Then
If ctrl.Text = "" Then
CheckValues = False
Exit Function
End If
End If
Next
CheckValues = True
End With
End Function

This is what i have so far. But when in the function the ctrl.text
property is empty when in the form there is tekst in the control.
Sorry, I don't understand the last sentence.
Is this because i am using an instance of the frmmain form ??
What else should you use? Of course you must use an instance of frmMain.
If i don't instanciate the frmmain form i can't acces the
properties.
Right
Does anyone know an answer on this??


I don't see the point. If you don't have a form, there are no textboxes or
comboboxes to check.
--
Armin

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: RC | last post by:
I have a table that lists many box numbers. Each box number has a Pallet Number (indicating which pallet the box is in). When the Pallets are loaded into a shipping Container I need to update the...
1
by: Jozef | last post by:
Hello, I'm trying to loop through forms by doing a "For Each" in the Currentdb. I'm doing this like the following; Dim db as dao.database Dim docLoop as document Dim ctrl as control Set db...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
2
by: Shawn | last post by:
Hi. I'm trying to loop through all webcontrols in my System.Web.UI.HtmlControls.HtmlForm. This is my code: Dim form As HtmlForm Dim control As Control form = Me.FindControl("completion")...
5
by: Mattia Saccotelli | last post by:
Hi to all. I'm trying to auto-save a form to XML using Page.Controls property. Almost everything is fine, except a really weird behavior with the HtmlTextArea control. I noticed that if it has a...
7
by: astro | last post by:
I am not farmilar with the object model for webforms. I want to loop through the web form controls - pulling out the checkboxes on the form like the following: For Each ctrl In Me.Controls ...
1
by: Jim in Arizona | last post by:
Using VB .. Is there a way to loop through all drop down lists on a web form checking for a specific value (ddlDropDown.SelectedValue) and then, based on that value, cause a specific label to go...
2
by: pob | last post by:
Whats the difference between using a control or a listbox when looping thru a listbox. In example 1 it dims a listbox and an example 2 it dims a control. Please explain. Thanks in advance ...
0
Echooff3
by: Echooff3 | last post by:
I’m working on a security function that changes the state of a control based on your user role. So a control can be set to visible/invisible and enables/disabled based on the login’s user role. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.