|
-
Aug 5th, 2006, 08:01 AM
#1
Thread Starter
New Member
go to line of code?
I am still confused about something ? lol as usual,
at the end of my program/game i have a button that when pressed will inevitably go to a line of code which is my Form1_load private sub. i dont know how to get this to work cheers.
srry cant provide code
My VB Code = Very Basic Code
-
Aug 5th, 2006, 08:39 AM
#2
Re: go to line of code?
I hope I understood what you mean. You don't have to go to a line of code, it is enough to call for it.
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1_load(any,params,you,might,have)
End Sub
-
Aug 5th, 2006, 09:36 AM
#3
Re: go to line of code?
You should absolutely NOT be directly calling your Load event handler. If you want to execute some code from the Click event handler of this Button then do so. If you want to execute the same code from the Load event handler then put it in a method of its own and call that method from both places. Do NOT call event handlers directly, especially something as specific as the Load event handler.
-
Aug 5th, 2006, 09:59 AM
#4
Re: go to line of code?
Never had to do it so far, will keep it in mind, thx.
-
Aug 5th, 2006, 03:14 PM
#5
Addicted Member
-
Aug 5th, 2006, 03:38 PM
#6
Fanatic Member
Re: go to line of code?
Just out of curiosity, why is it bad practice to directly call an event handler?
-
Aug 5th, 2006, 04:00 PM
#7
Re: go to line of code?
Rather than calling event handlers, put the code into a sub, then call it from the handlers or anywhere else it needs to be called from. THe reason for not calling handlers directly is because of the Law of Unintended Concequences. Let's say you've got an event handler for the change event of a text box. And the event handler does stuff. Then from somewhere else in the code, you call the handler directly. Six months later you have to make a change to the handler for what ever reason, but it's not something you want changin for the code where you called it directly.... only you don't remember that it's called that way.... who knows what kind of reaction you'll get from it.
-tg
OG Tay sez, peace out!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|