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. validating text boxes

validating text boxes

Scheduled Pinned Locked Moved Visual Basic
helpcsharp
3 Posts 3 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 S 2 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

      Don't post the same message twice.

      "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

        S Offline
        S Offline
        Santosh metal
        wrote on last edited by
        #3

        You cannot compare the type of control with TextBox Class. The control has to be compared with the type of TextBox. Possibly the the code snippet will resolve your issue For Each ctrl As Control In Me.Controls If ctrl.GetType() Is GetType(TextBox) Then If ctrl.Text="" Then MessageBox.Show("Message",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) ctrl.Focus() End IF End If Next Santosh Metal

        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