Results 1 to 2 of 2

Thread: [RESOLVED] tag question

  1. #1

    Thread Starter
    Hyperactive Member binilmb's Avatar
    Join Date
    Nov 2005
    Location
    Kochi
    Posts
    472

    Resolved [RESOLVED] tag question

    hi all
    what is the use of tag in each controls in vb. dont much aware of it
    įňįl

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: tag question

    You can use the Tag property for a wide, wide variety of things. Once of the things I use it most for is to include or exclude controls when looping through them.

    Lets say you have several textboxs that you use to add records to a database and after each add you need to clear out most of them, but not all of them, and you don't want to have to explicity state which textbox should be cleared and which shouldn't in your code. For this, you can use the Tag property of the textbox. In this case, I would put "clear" in those that I wanted to clear out, and then to
    VB Code:
    1. Dim ctrl As Control
    2. For Each ctrl In Me.Controls
    3.      If TypeOf ctrl Is TextBox Then
    4.         If ctrl.Tag = "clear" Then
    5.            ctrl.Text = vbNullString
    6.        End If
    7.      End If
    8. Next
    Now, it will only clear out those textboxes that have the word "clear" in tag property and leave the rest alone.

    Basically, the use of the Tag property is limited only by imgination.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width