Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB.NET compile (VB.NET 2003)

    I have a simple form in VB with a single button. When user clicks on the button, a welcome message will be displayed. After everything is working fine, I then changed the button's name but did not change the name on the associated event. When I reran the program, it detected the error. However, if I indicated to ignore the error to continue, the program still worked fine. Why is that the case?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VB.NET compile (VB.NET 2003)

    In VB6 and earlier, the name of the event routine had to match the control. In VB.Net, the connection is made through the Handles statement, and .Net keeps that part current in the application generated code when you change a control name. It doesn't care about the name of the event procedure, only the name of the controls it handles. When you say it detected the error, what do you mean? If you got a build error, you need to tell it to cancel and click on the error to go to that line so you can fix it.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB.NET compile (VB.NET 2003)

    Originally I had a button called button1 and it displayed a message (msgbox "Hi Charlottee"). I then changed the name property of this button to button2 without changing the code. When I ran the program, it said "there were build errors" and asked me if I wanted to continue. If I replied Yes and then clicked on that button, it still displahed the message "Hi Charlottee" even though there was no source code associated with button2 (the newly renamed button) at all.

    I think the old way where VB6 handles the control name and the event is way better. At least it is not that confusing.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB.NET compile (VB.NET 2003)

    The .NET method is both clearer and easier to use.
    For example, it allows ont to associate several controls, even of different types, with the same sub.
    The event names are still there, justv is adifferent postion, and may be different from the sub name.

Posting Permissions

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