Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. help

help

Scheduled Pinned Locked Moved Visual Basic
helpcsharp
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    twsted f8
    wrote on last edited by
    #1

    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

    P C N R 4 Replies Last reply
    0
    • T 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

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • T 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

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        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 )

        1 Reply Last reply
        0
        • P Paul Conrad

          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

          T Offline
          T Offline
          twsted f8
          wrote on last edited by
          #4

          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.

          C P 2 Replies Last reply
          0
          • T twsted f8

            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.

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            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 )

            1 Reply Last reply
            0
            • T twsted f8

              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.

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • T 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

                N Offline
                N Offline
                Naji El Kotob
                wrote on last edited by
                #7

                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...

                T 1 Reply Last reply
                0
                • T 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

                  R Offline
                  R Offline
                  rohitsrivastava
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • N Naji El Kotob

                    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...

                    T Offline
                    T Offline
                    twsted f8
                    wrote on last edited by
                    #9

                    Hi Thanks for helping. I do have a group box on the form. I still got a bit of a qn? What do u mean by iterate over the controls of the form, How could I go about this? Thanks again. twsted f8

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups