1>------ Build started: Project: Major 2, Configuration: Debug Any CPU ------
1> COM Reference 'WMPLib' is the interop assembly for ActiveX control 'AxWMPLib' but was marked to be linked by the compiler with the /link flag. This COM reference will be treated as a reference and will not be linked.
1>C:\Users\James\Google Drive\School\SDD\VB Work\VB Task 2\Major 2\Major 2\My Project\Application1.Designer.vb(25,20): error BC30269: 'Public Sub New()' has multiple definitions with identical signatures.
1>C:\Users\James\Google Drive\School\SDD\VB Work\VB Task 2\Major 2\Major 2\My Project\Application1.Designer.vb(34,33): error BC30269: 'Protected Overrides Sub OnCreateMainForm()' has multiple definitions with identical signatures.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
What Have I done wrong?
Namespace My
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' or if you encounter build errors in this file, go to the Project Designer
' (go to Project Properties or double-click the My Project node in
' Solution Explorer), and make changes on the Application tab.
'
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterAllFormsClose
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.Major_2.Main_Screen
End Sub
End Class
End Namespace
This is the double up in the code but i don't know what too change in the Application Designer.
Cause of error:
It seems that VS sometimes duplicating the Application.Designer.vb files under the Application.myapp section, (or it could be caused by the human error like the author did.) and for the correctly working project it should only have ONE Application.Designer.vb file.
Solution:
To fix this error, you need to delete the extra Application.Designer.vb files. The result should be looks like the picture given in below.
So turns out google drive duplicated one of my files so there was two and it was opening both
Related
I keep on getting a Compilation Error user-defined type not defined.
The error is on "Public globalRibbon As IRibbonUI"
I added more references under tools to try and resolve the issue but I am still getting the compilation error
Option Compare Database
Option Explicit
Public globalRibbon As IRibbonUI
Public Sub onRibbonLoad(ByVal ribbon As IRibbonUI)
Set globalRibbon = ribbon
End Sub
Public Sub RibOpenForm(control As IRibbonControl)
DoCmd.OpenForm (control.Tag)
End Sub
Public Sub ControlEnabled(control As IRibbonControl, ByRef enabled)
Select Case control.ID
Case "Primary"
If CurrentProject.AllForms("Primary").IsLoaded Then
enabled = False
Else
enabled = True
End If
End Select
End Sub
I expect to be able to set custom ribbon controls however it is not working.
It seems something is wrong with COM references in your VBA environment. You may try to install the latest updates and/or repair Office.
Compilation Error user-defined type not defined
Open up the VBA editor and go to Tools | References.
Scroll down until you see the following entries:
Microsoft Access X.0 Object library.
Microsoft Office X.0 Object library.
If you have multiple versions, use the latest version.
Both entries should be selected.
I'm maintaining a DLL with logging feature. I wanted to add a ListBox parameter to a method of this DLL to allow on display logging.
Basically this dll could be described this way :
' Class loggingDll.loggingObject
Public Function processIt([...], aLogBox As Object)
' Simple test code lines...
Dim l As VB.ListBox
Set l = aLogBox
' [...]
End Function
The EXE comes with a GUI, a VB.ListBox included. This ListBox (let's call it LogBox) is passed to the DLL in a way looking like this :
' Exe DllCaller.Exe
Private Sub Form_Load()
Dim aLoggingObject as loggingDll.loggingObject
Set aLoggingObject = New loggingDll.loggingObject
aLoggingObject.processIt(LogBox)
End Sub
This works perfectly fine when I run the EXE. But when running the DLL in debug mode whith this EXE (Project->Properties->Debugging tab option "Start program" with the path to the EXE), I get an ugly "Type Mismatch" at Set l = aLogBox.
I added a spy on the aLogBox variable. TypeName(aLogBox) returns "ListBox", but the content of aLogBox is empty (although a VB.ListBox object is full of properties).
What's happening ? Why debug mode has not the same behaviour ?
Hello I am trying to do an exercise and keep getting this error when compiling.
Visual Basic error BC30456 'Form1' is not a member of 'WindowsApplication1'
I'm not sure how to fix it.
Below is my code:
Public Class frmCentsConverter
Private Sub txtAmount_TextChanged(sender As Object, e As EventArgs) Handles txtAmount.TextChanged
If IsNumeric(txtAmount.Text) Then
Dim NumberofCents As Integer
NumberofCents = CInt(txtAmount.Text)
lblDollars.Text = CStr(NumberofCents \ 100)
lblCents.Text = CStr(NumberofCents Mod 100)
End If
End Sub
Private Sub lblTitle_Click(sender As Object, e As EventArgs) Handles lblTitle.Click
End Sub
End Class
If you have renamed the startup form1 it is likely you also have to change the Startup form setting. You can find this setting to open 'My Project' in the 'Solution Explorer'. Select the Application section, change the 'startup form' as appropriate.
Hope this will help, Harrie
To set the startup form in Windows Forms
In Solution Explorer, right-click the project and choose Properties.
The Project property page opens with the Application properties displayed.
Choose the form you want as the startup form from the Startup Object drop-down list.
I got this information from this website:
https://msdn.microsoft.com/library/a2whfskf(v=vs.100).aspx
I can confirm this works on Visual Studio 2015 as well.
Under the tab, Application.Designer.vb
You'll see the following the code:
Me.MainForm = Global.WindowsApplication1.Form1
Change Form1 to your NEW form name.
Example: Changed Form 1 "Hello World" to frmHello
Original:
Me.MainForm = Global.WindowsApplication1.Form1
Change to:
Me.MainForm = Global.WindowsApplication1.frmHello
It could be a bug after form renaming.
Try to change file Application.myapp under Project Folded
<MainForm>Form1</MainForm>
p.s. Application.Designer.vb is created dynamically, so changes there would be overwritten after the next clean build.
This is how I fixed it.
Right click on the Name of your project and then click properties.
Locate the Target framework under the Applications tab.
Change it to ".NET Framework 4.5" (mine was on 4.5.2).
Click/accept/whatever it is to confirm your selection from the popup box.
Build/Rebuild solution.
This worked for me in VB.net 2015.
Good Luck!
I know how to fix it.
If you get this problem, open the error message by clicking the error line until Application.Designer.vb shows up & then find the "Form1" name in that place.
Sample in Application.Designer.vb tab:
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.aplikasi_set_diskumau.Form1
End Sub
I found the "Form1" name in that part of code, just replace that "Form1" with the name of your form.
I managed to solve this by changing to .NET Framework 3.5, clean and rebuild, then change back to 4.8. For some reason it seems 4.8 is not updating Application.Designer.vb properly. By the way, updating that file manually does not work, it will be overwritten in the next build.
I have VS 2012 with the main project as a Windows form application and an added project as a excel workbook. I have some code that are exactly the same on both projects so I am trying to save time by sharing that code.
From my excel project I added a reference to my windows form project and imported the namespace. I can access the public functions on my main project, but I cannot seem to be able to access my public subs.
I also tried creating a module a adding a link between the projects but that would cause me to also update the code in two places. Besides, I think that creating a link may also cause some issues at deployment.
For example, in my windows form project I have the following I want to access from my second project
Public Sub closeXLApp()
'This sub is called to close the application without
'saving any changes to the workbook. The sub closes
'the app, workbook and sheet and performs some garbage clean up
'as well making sure that the opened Excel instance is cleared from memory.
xlBook.Close(SaveChanges:=False)
xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
GC.Collect()
End Sub
On my second project I created a reference and imported the namespace as:
Imports Compensation_Template_Welcome_Page
So when I try to access the above public sub from my second project as:
Private Sub btnMinCloseProject_Click(sender As Object, e As EventArgs) Handles btnMinCloseProject.Click
'This procedure runs when the btnMinCloseProject is clicked. The
'procedure calls the function to close workbook without saving changes.
closeXLApp()
End Sub
I get an error saying that the sub is not declared or not accessible due to its protection level.
Is there a better way to accomplish this? Even if is a longer route, I just want it to make it efficient in the long run.
Thanks
You're sub closeXLApp() is not static (shared), so you need to create an instance of the class where this sub is containted and then call the sub.
I am trying to create an msi install for my windows service. The reason for creating an msi is that the intended users want to be able to quickly install the service with as-little intervention as possible.
i can get the service to install as a msi but i have a variable within my code that i need the user to define when the msi is being installed. the variable i require from the user is the file path which they want the xml files my service creates to be located.
i thought i could configure the app.config application settings to contain the file path that the xml files should be written to. However i'm struggling to do this and im not to sure if its the best way to do it?
I have my setup project that contains my executable and has my textbox which will contain the one variable from the user.
I have an installer class which contains my serviceinstaller and process installer. This is where im struggling to understand what i need to do next.
Do i need to override the install method? The current code of my installer class was automatically generated and is as follows:
Imports System.Configuration.Install
Imports System.Configuration
<System.ComponentModel.RunInstaller(True)> Partial Class ProjectInstaller
Inherits System.Configuration.Install.Installer
'Installer overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Component Designer
'It can be modified using the Component Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller()
Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller()
'
'ServiceProcessInstaller1
'
Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem
Me.ServiceProcessInstaller1.Password = Nothing
Me.ServiceProcessInstaller1.Username = Nothing
'
'ServiceInstaller1
'
Me.ServiceInstaller1.ServiceName = "Spotter"
Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic
'
'ProjectInstaller
'
Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1})
End Sub
Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller
Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller
End Class
I can even add the CustomActionData values. The string determines what gets passed into the context object that i used to collect the user value that is entered. param1 being my variable name.
I'm pretty much struggling with the installer code...i think?
One option to consider is using a third party installer, such as Installshield, that has builtin support for modification of xml configuration files, such as config files.
However, if you want to roll your own, you definitely need to override the Install method. Any parameters that you pass in CustomData will be available in the dictionary that is passed as a parameter to this method.
For example:
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
If Me.Context.Parameters.Count <> 0 Then
For Each sKey As String In Context.Parameters.Keys
Select Case sKey.ToUpper
Case "PARAM1"
' XML directory
Me.XMLDir = Context.Parameters(sKey)
End Select
Next
End If
End Sub
In cases like this, we always write the value to the registry so that the user doesn't have to re-enter it if they uninstall or reinstall.
I am not sure of the exact sequence of events for modifying the app.config, but you could write to the registry, then modify app.config when the service is first started.
You will probably also find that you need to remove the custom action from the Commit phase in order for your installer to work successfully.