Results 1 to 4 of 4

Thread: Indexing of textboxes ???

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    2

    Indexing of textboxes ???

    Hi,

    At last, I started using VB.NET, but I'm used to program in VB6.
    In VB6 I indexed my textboxes, so I could use the same sub for every
    textbox.lostfocus for example.

    Now in VB.NET that is impossible.
    Let's say I have 3 textboxes (TextBox1,TextBox2,TextBox3) but I would like to write a general lostfocus (for changing the backcolor) for all three of them. Is that possible ?

    Thanks in advance

  2. #2
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Re: Indexing of textboxes ???

    .Focus = false

  3. #3
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: Indexing of textboxes ???

    Is this what you are after?
    vb Code:
    1. Private Sub WhichTextBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) _
    2. Handles TextBox1.LostFocus, Textbox2.lostfocus, textbox3.lostfocus
    3.  
    4.     MessageBox.Show(DirectCast(sender, TextBox).Name)   'Display which one,
    5.  
    6. End Sub
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    2

    Re: Indexing of textboxes ???

    Thanks a lot Stimbo.
    Exactly what I was looking for.

    Filip

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