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.
Related
I'm creating a custom form for appointments in Outlook for a project (add catering request to a meeting) - this is my first rodeo at doing this - and I'm striking out big time regardless of my intense (and failing) Google-Fu.
With a new appointment open, on the developer tab, I select "Design This Form". I go to tab "(P.2)" and build a stupid-simple, two-object form... CheckBox1 and TextBox1. In properties, TextBox1.Visible is False. Click View Code and input the following...
Private Sub CheckBox1_Click()
if CheckBox1.value=True Then
Me.TextBox1.Visible = True
Else Me.TextBox1.Visible = False
End If
End sub
I then click "Run This Form" and see/click CheckBox1 but nothing happens. If I could make this run, I might be in business. But it won't. So, I look for a work-around.
Grasping at straws, I open "Visual Basic" and basically do the same thing - create a form "UserForm1" with the same two objects and add the same code. Click the go-button and it works as expected. The TextBox1 appears and disappears with the CheckBox1 state.
As I can make the code function, I would build everything I need in the Visual Basic editor, however... Here's the problem - I have absolutely no idea how to get the form I create here into the Outlook application as a tab or button or whatever. I basically want the custom form VBA editor to be a selectable option in any Appointment.
I have watched tutorials, read doc, saw something about creating a macro - but nothing was written/stated dumbed-down enough for me to follow.
So my question: How do I get the UserForm1 that's built in VBA Editor to appear in a New Appointment when a button is clicked in Outlook?
You need to add the Click event handler for the CheckBox control, not just paste the code to your custom form.
Following the June 13 2017 security update, users discovered published custom forms no longer worked because VBScript behind the form and some controls are blocked by default. See Custom Form Security Changes and Custom form script is now disabled by default for more information.
Microsoft disabled custom form script functionality. If you need it enabled, you'll need to set two keys, one to enable scripting and a second one with the message class name of each form that has code behind it. For example:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Outlook\Security
DWORD: DisableCustomFormItemScript
Value: 0 (to enable)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\16.0\Outlook\Forms\TrustedFormScriptList
REG_SZ: IPM.Contact.custom-form-name
Value: (leave blank)
In some cases, forms in secondary mailboxes and Public folders still don't work after the registry key settings. To fix this, enable scripts in the Trust Center:
Click File > Options. Then select Trust Center > Trust Center Settings > Email Security.
Under the Script in Folders section, click the checkbox for Allow script in shared folders and Allow script in Public folders and click OK and OK again to close out the windows.
I am using the asp.net web forms and whenever I want to edit the MyWebPage.aspx.vb file to add something in the Page_Load subroutine, I have to add a temporary asp button or something like that and double click it. Is there a shortcut to open it??
Thanks for your answer!
If you hover over the buttons at the top of the Solution Explorer pane, one of them is "Show all files". Click that, and you will be able to expand MyWebPage.aspx to show the MyWebPage.aspx.vb file.
Alternatively, you can use "View" menu -> "Code" if you have MyWebPage.aspx showing in the 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.
I'm really struggling to find out how to dynamically load a form when starting a VB.NET winforms application in VS2010.
Looking at existing answers such as this: Programmatically change the startup form on application launch?
Has not helped. I do not have a main method (that I can see) in my winforms project and when I go into the project properties I can only select a start-up form. But I have one of two forms to display on start-up depending on the user accessing the application.
I tried to set a loading form up which, in it's load event would call .Show() on the correct loading form after it had determined it and then the loading form would close itself down, but doing this led to both forms being closed.
Below are steps for VS2010 VB.NET Winforms select startup form programmatically.
1 : Go to My project from Solution Explorer
2 : Click on Application Tab--->Uncheck Enable application Framework
3 : Then Inside module create Sub like this
Public Sub Main()
MsgBox("called Main") 'This is testing
Login.Show() 'Set your start up form here
End Sub
4 : Again My Project--->Application Tab--->Startup Object--->Sub Main
5 : Thats it, It will give you message box and will show Login form.
Hope It will help you.
Thanks
Mahesh
Nevermind. I found in the properties a button to generate the MyApplication class in which I can access the startup event.
Another option is to use an MDI form. When it loads you can determine which child form to display.
Using Sub Main is the way I have done this forever but for some reason, MS has decided to make the norm, difficult. To use the Sub Main way, create a "Module" if you dont already have one. Put this code in there:
Sub Main()
Stop
End Sub
Now, in your project properties, assuming your are doing a standard WinForms application, on the "Application" tab, uncheck the "Enable Application Framework". This will allow you to see (and select) "Sub Main" in the "Startup Object" drop-down.
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.