How can i tell which form loads first? - vb.net

I have a program that has 2 forms (FormLogin, FormMain). When I try to debug I nothing happens and I think it's attempting to go to the incorrect Form. Is there a setting I am missing somewhere?

Go to the Project menu, at the bottom click YourProject Properties...
On the Application tab you will see an entry called Startup Form. From the dropdown you can pick which form is the starting object.
This information is stored in the My Project folder, Application.Designer.vb and Application.myapp files but you should just use the GUI to change the startup form unless you have a good reason to edit the auto generated files directly.

Related

How to find a form from many forms in vb6 on a existing project

I am working on a old project of vb6 which has hundreds if forms. I am able to run the application and have to fix a runtime error in a form which pop up. I don't know the name of the form and only have visual reference. I tried using debug but It has continues SQL statements running in a loop. Any advice is appreciated.
Thanks.
Search the code for the form caption, or the labels of controls on the form, using visual studio's "find in files" or simlar function of your favourite editor.
If the caption is set in the form design, this will take you to the .frm file the form is stored in. You can open this in Notepad or another editor to get the name of the class (which is usually the same as the filename).
If the caption is set in code, you can place a breakpoint on that line. Again, this will lead you to the code which instantiates the form.

main.vb, main.designer.vb and missing Form Designer

I have been working with "visual basic.net" on a "windows forms" application. While manipulating controls and adding event handlers I noticed the resultant code was being generated within a file named 'main.designer.vb'. However, if I look in the solution explorer for my project there is no 'main.designer.vb' file, just 'main.vb'.
This is not a colossal problem as it runs properly. However, having closed the 'form designer' window I now cannot reopen it! 'main.vb' has no option to 'view in form designer'.
Any advice on this?
Would it be possible to copy the contents of 'main.designer.vb' in to 'main.vb' and delete 'main.designer.vb' entirely? If I did this, the next time I manipulated the form would the code be added to 'main.vb' or would a new 'main.designer.vb' be created?
I seem to have sorted out the problem.
'main.vb' was completely empty. All the code I had generated and written directly was inside 'main.designer.vb'. However, once I made a class definition within 'main.vb':
Public Class main
End Class
and then cut/pasted all my custom event handler code and subroutines from 'main.designer.vb' to THAT class - all was well. 'main.vb' now shows the correct form icon and FINALLY offers the correct 'view designer' context menu option.
I am not sure why it happened in the first place though.
Look in the Solution Explorer in Visual Studio. In the toolbar in this window is a button called "Show all files". Click it.
Then every file in the projects folder is actually shown in the solution explorer. Expand the treenodes for the form and you will see the designer.vb.
There are also buttons for switching between code-view and designer view. Just remember to select the form in the solution explorer for the buttons to show the correct form in the designer.

Unintelligent textboxes in VS2008

I have a WinForm in a vb.net application. It has between 4 and 7 multiline textboxes. I want to be able to copy and paste information into or out of those textboxes but it appears to be impossible. There is no right-click cut copy or paste available and the keyboard shortcuts do not work either.
The properties of all textboxes are enabled, visible and have shortcuts enabled
Can anyone help please?
Create first a ContextMenuStrip.
Add new menuitem: 'Paste', set the menuItem's ShortcutKeys property to CTRL+V.
Set the (Rich)Textbox -> ContextMenuStrip property to created menu control.
Handle the 'Paste' menuitem click event.
Try the result.
Its seems to be a strange problem.Make sure that you are using the real textbox control and not some custom user control.
It is also possible that the changes you make in designer and code are not written into the exe.When you debug your project, you might be seeing an old version of your program in which the properties might be set to false. In that case you have to simply delete the exe in the bin\debug folder and rebuild your project.

Deleting menu item results index error ("source not found")

In VB.Net 2010, whenever I delete a menu item on a Windows Form (a Mainmenu1 object), an exception is thrown at run-time suggesting that there is an index value missing -- essentially a "source not found" error. Do I need to go into the Mainmenu1 object on the bottom of the Form at design time and do something? (BTW, I have also tried deleting the source code for the menu item, and then the menu item, and the exception is still thrown).
Basically, something is occurring that is not allowing me to simply delete a menu item, and get a successful run thereafter.
I had this problem. The simple fix is to restore the menu by clicking undo. Then run the code to make sure it still works. When you have done this, CLOSE visual studio. Then open VS and load your project. Delete the item from the menu and run the project. Everything should be fine
I think you need to specify whether you were trying to delete the menu or menu item during run time, or during design time.
You said, an exception, indicating an index value was missing, thrown at run time. I think it might be depending on how you deleted the menu item. You didn't mention how you deleted the menu item.
Normally, when you choose a menu item from a menu at design time, and press the Delete key, it disappeared. And, the program still works fine.
And, another possibility, is that your form window designer and the background designer code is not properly synced.
You might know that, every .NET form objects, have their background designer code, which serves as a schema for everything on the form.
When you add a button onto the form, the Visual Studio add a line of code in the designer code file (normally if your form name is form1, the designer code file is form1.designer.vb or cs or whatever). When you change the background colour of the button, designer code file add a line of code to set the button's background colour.
So, you see, in your case, when you delete the menu item, your designer code file probably didn't successfully remove the code relating to that menu item. So, it throws an exception at run time.
Maybe, it's because of your Visual Studio installation.
So, my suggestion is, you should try debugging the project, line by line, by running the project with F6 or F11 (sorry, I don't remember the exact key, but you can find it in the Debug menu).
I hope I made a good sense for your problem!

How do I set the default form in vb.Net?

How do I set form number four as the default form that will run when I press on f5 in visual studio 2008. Because form 1 will always be the first to start
Right-click on your project in solution explorer.
Choose properties.
Select the Application Tab.
Select your form from the dropdown under 'startup form'
In the Project Properties, there's a field called "Startup form" - select your form in there.
Right-click your Project within the Solution Explorer.
Choose Properties.
Select the Web tab on the left-hand side.
Under the Start Page section, define the Specific Page you would
like to default to when the application is launched.
Save your changes.
Right-click your Project within the Solution Explorer.
Choose Properties.
Select the Web tab on the left-hand side.
Under the Start Page section, define the Specific Page you would like to default to when the application is launched.
Save your changes.
The other solutions work, but they will disable the use of ApplicationEvents like Startup, because the startup object has to be Sub Main for those to work.
To change the form started by Sub Main, do the following:
Close your project in Visual Studio.
Open your project's folder in explorer.
In it, open folder My Project.
Open Application.myapp with any text editor.
Change the form between the <MainForm> tags to your (new) main forms name.
Save and close.
Open ApplicationDesigner.vb with any text editor.
Find the following line and change YourMainFormsName to your (new) main forms name:
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.YourProjectsName.YourMainFormsName
End Sub
Save and close.
Open your project again and start it up. The startup form should have changed.
In my case, it doesn't work immediately from project properties. I have to close the solution and re-open it in order to see the latest form you have created and if you intend to make a startup object.