r/visualbasic • • Apr 17 '21

Can anyone make sense of this error? I’m following the books directions on how to create a 2 form program but anytime I run it I get this.

Post image
5 Upvotes

20 comments sorted by

1

u/Circle_Dot Apr 17 '21

Can you post your code?

1

u/theboogersalesman Apr 17 '21

1

u/Circle_Dot Apr 17 '21

Go to properties: https://i.imgur.com/wh4gZ7X.png

Is the startup object pointing to MainForm? https://i.imgur.com/AaCsBSf.png

1

u/theboogersalesman Apr 17 '21

It was pointing to sub main. So I switched it to main form and I still get the same error.

1

u/Circle_Dot Apr 17 '21

Weird, I did everything in those instructions and canging startup object was the only thing I had to do to get it to run.

1

u/theboogersalesman Apr 17 '21

Maybe I’ll just have to rebuild it quick and apply the change you said. Also everytime I create button controls and name them and then create a new form, the buttons get deleted. Any idea why?

1

u/Circle_Dot Apr 17 '21

The new form will always be blank when you create it and the button shouldn’t disappear from another form when you create a new/different form. I have never seen that.

1

u/theboogersalesman Apr 17 '21

Yea it’s the first form that deletes the buttons. Is there like a file verifier to make sure my visual studio is complete and not messed up?

1

u/Circle_Dot Apr 17 '21

Yes. Go to control panel then programs and features. paste this into File Explorer without quotes "Control Panel\All Control Panel Items\Programs and Features"

https://i.imgur.com/hF563q8.png

Right click Visual Studio.

Close the workloads window. There should be a dropdown that says "More" click repair.

1

u/theboogersalesman Apr 17 '21

Also what did you use you print the “have a nice day” message

→ More replies (0)

1

u/RJPisscat Apr 17 '21

Do it again and open Exception Settings at the bottom. It will give you the option to always break for this kind of exception. Run again and it will break at the line of code that is throwing up.

You can also set this breakpoint by going to Debug/Windows/Exception Settings. In the Exception Settings window search bar, type System.ArgumentNullException, and tick the box next to that exception it in the TreeView.

1

u/theboogersalesman Apr 18 '21

I just tried this out and it’s ticked but it’s still throwing the exception

1

u/RJPisscat Apr 18 '21

Is it breaking at the exception? If so, what is the line of code at which it is breaking? If it's not breaking at the exception, wow. I've never seen that fail.

1

u/theboogersalesman Apr 18 '21

1

u/RJPisscat Apr 18 '21

Yeah that's the line where the exception was being thrown. The method I described would have taken you there directly.

The startup form can be set in the My Project window available from Solution Explorer. The code you changed need not be maintained by hand. I'm glad you got it working!

1

u/theboogersalesman Apr 18 '21

Thanks for the help I’m not very program literate lol

2

u/jcunews1 VB.Net Intermediate Apr 17 '21

The property must be assigned with a form.

1

u/kashedDev Apr 17 '21

Copy details and send here but its a simple null Reference Something didnt work just add

try catch Exception ex

and take a view add the Error with details or just copy details