r/visualbasic • • Feb 07 '19

Form1_Load not working

I have the following code in my project:

Private sub Form1_Load(sender as object, e as eventargs) handles mybase.load Msgbox("it worked") End sub

For some reason, this sub is not being called when the program is run. Please help.

(I tried the same code in a new project and it worked fine)

5 Upvotes

5 comments sorted by

2

u/CityEggs VB.Net Beginner Feb 07 '19

Messagebox.show("it worked now")

2

u/[deleted] Feb 07 '19

messagebox.show("it worked")

1

u/dryguy5 Feb 07 '19

Does the form actually load?

If this form isn't called from another, check your application settings and make sure Form1 is the Startup Object.

1

u/Mastersord Feb 08 '19

Is this winforms or WPF? Off-hand I remember using form.Initialized and form.Loaded events in WPF. I don’t remember what I did for winforms as I’ve mostly migrated away from it.

I’ve also made and called a publicly exposed sub when calling a form from another form or even from a main method, in order to initialize the form.

1

u/chrisand1998 Feb 08 '19

In visualstudio go to your application property's and make sure Form1 is your startup form. Also the command msgbox doesn't work and should be messagebox.show("*")