Handlers in VB .NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kim C

    #1

    Handlers in VB .NET

    I have several textboxes and I want one dbl click handler to be used for all
    of the textboxes. How do I set that handler for all of the text boxes? I
    know
    how to set it for one, but how do I get all of the text boxes to use the
    same
    handler?

    Kim
    I


  • Rick Rothstein

    #2
    Re: Handlers in VB .NET

    Almost everybody in this newsgroup is using VB6 or lower. While you may
    get a stray answer to VB.NET questions here, you should ask them in
    newsgroups devoted exclusively to .NET programming. Look for newsgroups
    with either the word "dotnet" or "vsnet" in their name.

    For the microsoft news server, try these newsgroups...

    microsoft.publi c.dotnet.genera l
    microsoft.publi c.dotnet.langua ges.vb
    microsoft.publi c.vsnet.general

    There are some others, but these should get you started.

    Rick - MVP



    "Kim C" <kim_c@cox.ne t> wrote in message
    news:1tcOc.117$ 73.48@lakeread0 4...[color=blue]
    > I have several textboxes and I want one dbl click handler to be used[/color]
    for all[color=blue]
    > of the textboxes. How do I set that handler for all of the text boxes?[/color]
    I[color=blue]
    > know
    > how to set it for one, but how do I get all of the text boxes to use[/color]
    the[color=blue]
    > same
    > handler?
    >
    > Kim
    > I
    >
    >[/color]

    Comment

    • Kim C

      #3
      Re: Handlers in VB .NET

      Thanks Rick!

      "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
      news:Jdudnd49D6 tj_5TcRVn-uQ@comcast.com. ..[color=blue]
      > Almost everybody in this newsgroup is using VB6 or lower. While you may
      > get a stray answer to VB.NET questions here, you should ask them in
      > newsgroups devoted exclusively to .NET programming. Look for newsgroups
      > with either the word "dotnet" or "vsnet" in their name.
      >
      > For the microsoft news server, try these newsgroups...
      >
      > microsoft.publi c.dotnet.genera l
      > microsoft.publi c.dotnet.langua ges.vb
      > microsoft.publi c.vsnet.general
      >
      > There are some others, but these should get you started.
      >
      > Rick - MVP
      >
      >
      >
      > "Kim C" <kim_c@cox.ne t> wrote in message
      > news:1tcOc.117$ 73.48@lakeread0 4...[color=green]
      > > I have several textboxes and I want one dbl click handler to be used[/color]
      > for all[color=green]
      > > of the textboxes. How do I set that handler for all of the text boxes?[/color]
      > I[color=green]
      > > know
      > > how to set it for one, but how do I get all of the text boxes to use[/color]
      > the[color=green]
      > > same
      > > handler?
      > >
      > > Kim
      > > I
      > >
      > >[/color]
      >[/color]


      Comment

      • Hal Rosser

        #4
        Re: Handlers in VB .NET

        write the code for one - then -
        at the sub declaration where it says "handles textBox1.DblCli ck" - add a
        comma, and then "TextBox2.DblCl ick, TextBox3.DblCli ck, ... etc
        the "handles" clause tells VB which events it handles

        "Kim C" <kim_c@cox.ne t> wrote in message news:1tcOc.117$ 73.48@lakeread0 4...[color=blue]
        > I have several textboxes and I want one dbl click handler to be used for[/color]
        all[color=blue]
        > of the textboxes. How do I set that handler for all of the text boxes? I
        > know
        > how to set it for one, but how do I get all of the text boxes to use the
        > same
        > handler?
        >
        > Kim
        > I
        >
        >[/color]


        ---
        Outgoing mail is certified Virus Free.
        Checked by AVG anti-virus system (http://www.grisoft.com).
        Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004


        Comment

        • Eddie B

          #5
          Re: Handlers in VB .NET

          The is easier in VB.Net, but I assume you are using VB6 or earlier

          You could write an event handler, and assign it all text boxes. This
          woould be very easy, if you are using an array of text boxes (ie
          txtBox(1), txtBox(2), txtBox(3)) if not, the only way I know how is
          like this..

          Start a VB project and add 4 text boxes to the form (textbox1,
          textbox2...)

          Replace any code in the forms code window with this...

          Private WithEvents ctlTextBox As TextBox

          Private Sub ctlTextBox_Clic k()
          MsgBox ("A box was clicked")
          End Sub

          Private Sub Text1_Click()
          Call ctlTextBox_Clic k
          End Sub

          Private Sub Text2_Click()
          Call ctlTextBox_Clic k
          End Sub

          Private Sub Text3_Click()
          Call ctlTextBox_Clic k
          End Sub

          Private Sub Text4_Click()
          Call ctlTextBox_Clic k
          End Sub

          Everytime you click on a text box, the ctlTextBox_Clic k event will
          fire.

          Hope this helps :)

          On Sat, 31 Jul 2004 03:39:10 -0400, "Hal Rosser"
          <hmrosser@bells outh.net> wrote:
          [color=blue]
          >write the code for one - then -
          >at the sub declaration where it says "handles textBox1.DblCli ck" - add a
          >comma, and then "TextBox2.DblCl ick, TextBox3.DblCli ck, ... etc
          >the "handles" clause tells VB which events it handles
          >
          >"Kim C" <kim_c@cox.ne t> wrote in message news:1tcOc.117$ 73.48@lakeread0 4...[color=green]
          >> I have several textboxes and I want one dbl click handler to be used for[/color]
          >all[color=green]
          >> of the textboxes. How do I set that handler for all of the text boxes? I
          >> know
          >> how to set it for one, but how do I get all of the text boxes to use the
          >> same
          >> handler?
          >>
          >> Kim
          >> I
          >>
          >>[/color]
          >
          >
          >---
          >Outgoing mail is certified Virus Free.
          >Checked by AVG anti-virus system (http://www.grisoft.com).
          >Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004
          >[/color]

          Comment

          • Kim C

            #6
            Re: Handlers in VB .NET

            Actually I am using VB .NET. How would you do it in .NET?



            <Eddie B> wrote in message
            news:2qqog09j5m 7gp5jtaadhhjtu8 3hhca1cn1@4ax.c om...[color=blue]
            > The is easier in VB.Net, but I assume you are using VB6 or earlier
            >
            > You could write an event handler, and assign it all text boxes. This
            > woould be very easy, if you are using an array of text boxes (ie
            > txtBox(1), txtBox(2), txtBox(3)) if not, the only way I know how is
            > like this..
            >
            > Start a VB project and add 4 text boxes to the form (textbox1,
            > textbox2...)
            >
            > Replace any code in the forms code window with this...
            >
            > Private WithEvents ctlTextBox As TextBox
            >
            > Private Sub ctlTextBox_Clic k()
            > MsgBox ("A box was clicked")
            > End Sub
            >
            > Private Sub Text1_Click()
            > Call ctlTextBox_Clic k
            > End Sub
            >
            > Private Sub Text2_Click()
            > Call ctlTextBox_Clic k
            > End Sub
            >
            > Private Sub Text3_Click()
            > Call ctlTextBox_Clic k
            > End Sub
            >
            > Private Sub Text4_Click()
            > Call ctlTextBox_Clic k
            > End Sub
            >
            > Everytime you click on a text box, the ctlTextBox_Clic k event will
            > fire.
            >
            > Hope this helps :)
            >
            > On Sat, 31 Jul 2004 03:39:10 -0400, "Hal Rosser"
            > <hmrosser@bells outh.net> wrote:
            >[color=green]
            > >write the code for one - then -
            > >at the sub declaration where it says "handles textBox1.DblCli ck" - add a
            > >comma, and then "TextBox2.DblCl ick, TextBox3.DblCli ck, ... etc
            > >the "handles" clause tells VB which events it handles
            > >
            > >"Kim C" <kim_c@cox.ne t> wrote in message[/color][/color]
            news:1tcOc.117$ 73.48@lakeread0 4...[color=blue][color=green][color=darkred]
            > >> I have several textboxes and I want one dbl click handler to be used[/color][/color][/color]
            for[color=blue][color=green]
            > >all[color=darkred]
            > >> of the textboxes. How do I set that handler for all of the text boxes?[/color][/color][/color]
            I[color=blue][color=green][color=darkred]
            > >> know
            > >> how to set it for one, but how do I get all of the text boxes to use[/color][/color][/color]
            the[color=blue][color=green][color=darkred]
            > >> same
            > >> handler?
            > >>
            > >> Kim
            > >> I
            > >>
            > >>[/color]
            > >
            > >
            > >---
            > >Outgoing mail is certified Virus Free.
            > >Checked by AVG anti-virus system (http://www.grisoft.com).
            > >Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004
            > >[/color]
            >[/color]


            Comment

            • Eddie B

              #7
              Re: Handlers in VB .NET

              Hal has it right, do that :)

              On Mon, 2 Aug 2004 14:34:28 -0400, "Kim C" <kim_c@cox.ne t> wrote:
              [color=blue]
              >Actually I am using VB .NET. How would you do it in .NET?
              >
              >
              >
              ><Eddie B> wrote in message
              >news:2qqog09j5 m7gp5jtaadhhjtu 83hhca1cn1@4ax. com...[color=green]
              >> The is easier in VB.Net, but I assume you are using VB6 or earlier
              >>
              >> You could write an event handler, and assign it all text boxes. This
              >> woould be very easy, if you are using an array of text boxes (ie
              >> txtBox(1), txtBox(2), txtBox(3)) if not, the only way I know how is
              >> like this..
              >>
              >> Start a VB project and add 4 text boxes to the form (textbox1,
              >> textbox2...)
              >>
              >> Replace any code in the forms code window with this...
              >>
              >> Private WithEvents ctlTextBox As TextBox
              >>
              >> Private Sub ctlTextBox_Clic k()
              >> MsgBox ("A box was clicked")
              >> End Sub
              >>
              >> Private Sub Text1_Click()
              >> Call ctlTextBox_Clic k
              >> End Sub
              >>
              >> Private Sub Text2_Click()
              >> Call ctlTextBox_Clic k
              >> End Sub
              >>
              >> Private Sub Text3_Click()
              >> Call ctlTextBox_Clic k
              >> End Sub
              >>
              >> Private Sub Text4_Click()
              >> Call ctlTextBox_Clic k
              >> End Sub
              >>
              >> Everytime you click on a text box, the ctlTextBox_Clic k event will
              >> fire.
              >>
              >> Hope this helps :)
              >>
              >> On Sat, 31 Jul 2004 03:39:10 -0400, "Hal Rosser"
              >> <hmrosser@bells outh.net> wrote:
              >>[color=darkred]
              >> >write the code for one - then -
              >> >at the sub declaration where it says "handles textBox1.DblCli ck" - add a
              >> >comma, and then "TextBox2.DblCl ick, TextBox3.DblCli ck, ... etc
              >> >the "handles" clause tells VB which events it handles
              >> >
              >> >"Kim C" <kim_c@cox.ne t> wrote in message[/color][/color]
              >news:1tcOc.117 $73.48@lakeread 04...[color=green][color=darkred]
              >> >> I have several textboxes and I want one dbl click handler to be used[/color][/color]
              >for[color=green][color=darkred]
              >> >all
              >> >> of the textboxes. How do I set that handler for all of the text boxes?[/color][/color]
              >I[color=green][color=darkred]
              >> >> know
              >> >> how to set it for one, but how do I get all of the text boxes to use[/color][/color]
              >the[color=green][color=darkred]
              >> >> same
              >> >> handler?
              >> >>
              >> >> Kim
              >> >> I
              >> >>
              >> >>
              >> >
              >> >
              >> >---
              >> >Outgoing mail is certified Virus Free.
              >> >Checked by AVG anti-virus system (http://www.grisoft.com).
              >> >Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004
              >> >[/color]
              >>[/color]
              >[/color]

              Comment

              Working...