|
-
Feb 4th, 2011, 01:02 PM
#1
Thread Starter
Lively Member
Execute subroutine at startup
I am trying to execute the "Data()" subroutine at startup. This did not work:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Data()
End Sub
Is there a way to call the subroutine at the begining of debug?
-
Feb 4th, 2011, 03:22 PM
#2
Re: Execute subroutine at startup
What did not work about that call (though you don't ever need to use the Call word, it's a holdover that can be forgotten)? Did it not happen early enough? If that's the issue, then you can move the call earlier in the process, such as to the form constructor (which is not immediately obvious, but can be found in the .designer.vb file associated with the form).
My usual boring signature: Nothing
 
-
Feb 4th, 2011, 04:45 PM
#3
Re: Execute subroutine at startup
Can you explain what "did not work"? That is, tell us what your expected result is and what the actual outcome you have now.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 4th, 2011, 07:08 PM
#4
Thread Starter
Lively Member
Re: Execute subroutine at startup
It should have made the call when the form was loaded.
-
Feb 4th, 2011, 07:51 PM
#5
Member
Re: Execute subroutine at startup
Put a breakpoint at Call Data()
Use "Step Into" <F8> , What happens?
-
Feb 4th, 2011, 09:38 PM
#6
Thread Starter
Lively Member
Re: Execute subroutine at startup
I put a breakpoint at Call Data() then <F8>.
No errors just Highlighted in YELLOW:
Dim gphFormGraphics as Graphics = Me.CreateGraphics
-
Feb 4th, 2011, 09:41 PM
#7
Re: Execute subroutine at startup
-
Feb 4th, 2011, 09:52 PM
#8
Thread Starter
Lively Member
Re: Execute subroutine at startup
This just highlights the line. What to do next?
-
Feb 4th, 2011, 10:03 PM
#9
Re: Execute subroutine at startup
That line of code IS being executed. That I can guarantee. What may be happening is that the method you're calling is throwing an exception. In Windows 7, exceptions thrown in the Load event handler of the startup form are swallowed without obvious notification.
You are obviously doing something wrong because you should basically NEVER be calling CreateGraphics. It's especially useless in the Load event handler because the form hasn't even been displayed yet, so anything you draw will never be seen.
Please explain what you're actually trying to achieve. Showing us the contents of the is Data method would help also.
Finally, "Data" is a very poor name for a method. Method names should be verb-based for a start, because they represent behaviour. Something like "GetData" would be more appropriate, but you might be able to come up with a better name still because you know what the method actually does.
-
Feb 5th, 2011, 12:39 AM
#10
Member
Re: Execute subroutine at startup
Can you "Cut and Paste" us some of your code so we can get an idea of what you are doing?
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
|