help
-
Hi I am kinda new to vb.net and I am having problems with code that works when it suits it. The code is meant to check if data has been entered into the text boxes. For some unknown reason it works on one form but the same code copied and pasted does not work on a different form. this the code. 'This checks the textboxes to see if the data entered is correct Dim ctrlx As Control For Each ctrlx In Controls If TypeOf ctrlx Is TextBox Then If ctrlx.Text = "" Then ctrlx.Focus() MessageBox.Show("Please enter the required data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If End If Next I hope u will be able to help me, twsted f8
-
Hi I am kinda new to vb.net and I am having problems with code that works when it suits it. The code is meant to check if data has been entered into the text boxes. For some unknown reason it works on one form but the same code copied and pasted does not work on a different form. this the code. 'This checks the textboxes to see if the data entered is correct Dim ctrlx As Control For Each ctrlx In Controls If TypeOf ctrlx Is TextBox Then If ctrlx.Text = "" Then ctrlx.Focus() MessageBox.Show("Please enter the required data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If End If Next I hope u will be able to help me, twsted f8
twsted f8 wrote:
it works on one form but the same code copied and pasted does not work on a different form
What is not working? Be a little more descriptive.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Hi I am kinda new to vb.net and I am having problems with code that works when it suits it. The code is meant to check if data has been entered into the text boxes. For some unknown reason it works on one form but the same code copied and pasted does not work on a different form. this the code. 'This checks the textboxes to see if the data entered is correct Dim ctrlx As Control For Each ctrlx In Controls If TypeOf ctrlx Is TextBox Then If ctrlx.Text = "" Then ctrlx.Focus() MessageBox.Show("Please enter the required data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If End If Next I hope u will be able to help me, twsted f8
twsted f8 wrote:
I am having problems with code that works when it suits it.
This is almost certainly not true. Most likely, on one form you have an event set up to call this method, and on the other, you do not.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
twsted f8 wrote:
it works on one form but the same code copied and pasted does not work on a different form
What is not working? Be a little more descriptive.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
Hi Paul The code is meant to check all the text boxes on a form. If a blank field is found the user a msgbox is displayed asking the user to enter the required information. Similarly the code can also be used to check each text box to see if the data entered is of the correct type. On the first form code identifies all the textboxes that have been left blank. On the 2nd form this same code does not work. When I click the button, nothing happens, the blank textboxes are not identified and no error messagebox is displayed, of which when I do the same thing on the first form the program is able to pick up all the blank fields.
-
Hi Paul The code is meant to check all the text boxes on a form. If a blank field is found the user a msgbox is displayed asking the user to enter the required information. Similarly the code can also be used to check each text box to see if the data entered is of the correct type. On the first form code identifies all the textboxes that have been left blank. On the 2nd form this same code does not work. When I click the button, nothing happens, the blank textboxes are not identified and no error messagebox is displayed, of which when I do the same thing on the first form the program is able to pick up all the blank fields.
Is this code being called in both forms ? Do you have breakpoints so you can see what is going on ?
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi Paul The code is meant to check all the text boxes on a form. If a blank field is found the user a msgbox is displayed asking the user to enter the required information. Similarly the code can also be used to check each text box to see if the data entered is of the correct type. On the first form code identifies all the textboxes that have been left blank. On the 2nd form this same code does not work. When I click the button, nothing happens, the blank textboxes are not identified and no error messagebox is displayed, of which when I do the same thing on the first form the program is able to pick up all the blank fields.
Like Christian said, is it being called by both? Have you tied in any event procedures to call it?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
Hi I am kinda new to vb.net and I am having problems with code that works when it suits it. The code is meant to check if data has been entered into the text boxes. For some unknown reason it works on one form but the same code copied and pasted does not work on a different form. this the code. 'This checks the textboxes to see if the data entered is correct Dim ctrlx As Control For Each ctrlx In Controls If TypeOf ctrlx Is TextBox Then If ctrlx.Text = "" Then ctrlx.Focus() MessageBox.Show("Please enter the required data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If End If Next I hope u will be able to help me, twsted f8
Hi, Do you host your textboxes into sub-containers (e.g. Groupbox, Panel, ...) If yes, then you must iterate over the controls of sub-containers. Hope this helps :)
NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...
-
Hi I am kinda new to vb.net and I am having problems with code that works when it suits it. The code is meant to check if data has been entered into the text boxes. For some unknown reason it works on one form but the same code copied and pasted does not work on a different form. this the code. 'This checks the textboxes to see if the data entered is correct Dim ctrlx As Control For Each ctrlx In Controls If TypeOf ctrlx Is TextBox Then If ctrlx.Text = "" Then ctrlx.Focus() MessageBox.Show("Please enter the required data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If End If Next I hope u will be able to help me, twsted f8
i check what u have written is also not working what i will give u this is the correct coding copy it Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is TextBox Then ctrl.Text = "" End If Next
-
Hi, Do you host your textboxes into sub-containers (e.g. Groupbox, Panel, ...) If yes, then you must iterate over the controls of sub-containers. Hope this helps :)
NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...