Can't run Startup form - vb.net

As usual, I change the startup form under Application tab. At this time, it doesn't run my selected Startup form. Whatever I set to any forms or even excluding that form, it still runs the same form. Why does it happen?

Try deleting .pdb file in debug directory and start with Build > Clean [Your SolutionName]

Check the <MainForm> element in <project>\My Project\Application.myapp.
If it's still not working right then check the code in <project>\My Project\Application.Designer.vb and look at the sub OnCreateMainForm. This is where the form is assigned to the main form property of the application.
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.<ApplicationName>.<FormName>
End Sub

Just rebuilding the project will do the trick

try to delete the \bin and \obj directories. Then clean & rebuild.

Related

Button not displayed while running the program

I am using vb.net 2008, I added a button from design view in one of my forms.It shows in the form design view, I gave it the click code to load another form but after I run the program and look in that form, it does not show the button that I added while I run the program. what is the problem? And What are the solutions?
Thanks!
As you can see, I added a Back Button here
THis image is while I run the program. Back button is not displayed here.
I would suggest running something like this in order to see if the control is there. Listing if it is Visible would also be helpful.
https://stackoverflow.com/a/12985464/7340880
Private Sub GetControls()
For Each GroupBoxCntrol As Control In Me.Controls
If TypeOf GroupBoxCntrol Is GroupBox Then
For Each cntrl As Control In GroupBoxCntrol.Controls
'do somethin here
Next
End If
Next
End Sub
The only way I can help you without you providing us more information like code or error info if exist (or maybe a warning), I will suggest you to copy the code from your button then delete the current button and a new one. Then paste the code back to new button.
And make sure you don't hide or change the visible property button somewhere in the code. If you are working with positioning in the code make sure you don't move your button.
Thank you for your support. The problem was that it was running the old .exe file. I deleted the old .exe file from the /bin/debug directory. And after I ran the program, it created me a new .exe file and hence my problem was solved.
Thank you again.

application open on startup in background

Apologies if this question has already been asked.
I currently have it in the startup folder, but I'm not sure what code to use to not open the parent form.
I want my vb.net application to open on startup but in the background so it doesn't annoy users when they log in.
How would i go about setting that up?
To prevent a form from showing itself (but still create itself) you can override the following code in the form.
Protected Overrides Sub SetVisibleCore(value As Boolean)
MyBase.SetVisibleCore(False)
End Sub
This will always hide your form. Obviously pass true to make it display on whatever criteria you'd like to use.
This approach doesn't require you to restructure your application to separate ui + logic.
Try to move all the form init code to a sub Main function in a new module a set that function as a start up function, after the init code add:
dim frm as new <your_form>
after when you want to display it only call frm.show or frm.showdialog

Error on Load Event when using My.Settings

I am currently having an issue with the usage of embedded settings in my application. I intend to use them with the form load/closing event, but I am recieving an error like this user:
Error when loading mySettings [Visual basics 2010]
I looked at my settings.vb file and everything appears to be in order, but I am not really sure what could have become incorrect/corrupt because it is all generated when I make changes to the project properties. In order to check if my usage of the settings was correct I created a new project with:
Private Sub Load()
Textbox1.Text = My.Settings.Test
End Sub
Private Sub Close()
My.Settings.Test = TextBox1.Text
End Sub
Everything is working perfectly in the new project, so the error is isolated to my particular project. Has anyone encountered this or have any ideas on how to remedy it?
Thanks for any help!
Exact Same Error from another user:
For those people googling this in the future here is the solution in my case:
Click View Detail and continue navigation through the error detail until you find the path to the app.config file. Once you find it move it to a backup location and run your app again. The file will be regenerated correctly.

VB.net program with no UI

I'm making a VB.net program via a text file and I'm compiling it using vbc.exe via command line. I'm trying to get just a simple program to run in the background of my computer. Problem is, it displays the annoying console window. How do I get nothing to show? No form, no console?
Just use windows forms application don't load the form at all! Just go in project properties and uncheck enable application framework. Now, in the startup object dropdown, select "sub main". Add a module to the project and put a Public Sub Main() in it. You do all the stuff in main() and don't load form at all.
I think you need a form of some kind to keep the message loop going.
Maybe a NotifyIcon type program. It would keep it away from the task bar and desktop areas.
And then customize the NotifyIcon to "Only Show Notifications" from the "Customize" menu for your icon using Windows.
1) Add a module in your project, and create Sub Main
2) Write whatever you want in Sub Main,and MAKE SURE you end it with this statement:
Application.Run()
3) Open properties of your project and choose "Sub Main" as startup object
So , your application will have NO INTERFACE (NO FORM / NOT CONSOLE APPLICATION) and will run from Sub Main(), in addition it will NOT TERMINATE once all the code in Sub Main has executed.Your program will run like a NORMAL windows form application, and will only exit when you want.

Getting Startup Location In Windows

I've written a small program to open at startup, but I want to give the user the ability to delete it from showing on startup by clicking a button.
But it needs to be compatible on XP, Vista and Windows 7.
Is there a line of code which will get the default startup folder path automatically so I can then delete it using my button?
Thank you in advance
What you are wanting is the SpecialFolder.Enumeration. and use the Environment methods
Something like this Environment.GetFolderPath(Environment.SpecialFolder.Startup)
To do your deletion you need to use System.IO.File.Delete(path)
To check to see what files are out there try making a console application and use this code.
Module Module1
Sub Main()
Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup)
For Each file In System.IO.Directory.GetFiles(path)
Console.WriteLine(file)
Next
Console.ReadLine()
End Sub
End Module