Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7708541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:38:19+00:00 2026-06-01T00:38:19+00:00

How can you write a VB.NET Windows Forms Application via CodeDom? I have tried

  • 0

How can you write a VB.NET Windows Forms Application via CodeDom?

I have tried everything, the closest i got to it is the code below, which first of all shows command prompt window which is not good, and then shows the form for like a second and everything disappears.
Is there another proper way to do it? An example is greatly appreciated.

Public Module MyApp
    Public Sub main()
        Dim NewForm As New System.Windows.Forms.Form
        NewForm.Name = "Form1"
        NewForm.Text = "Form1"
        NewForm.Width = 300
        NewForm.Height = 300
        NewForm.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
        NewForm.ControlBox = True
        NewForm.MaximizeBox = False
        NewForm.MinimizeBox = True
        NewForm.Show()
    End Sub
End Module
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:38:20+00:00Added an answer on June 1, 2026 at 12:38 am

    After alot of research online, i have came to the following conclusion which seems to be working just fine.
    Thanks to everybody for any input on this subject.

    First of all open a new project add the following code to a button.
    This code compiles the code that you write in the text file that you will create in the next step.

      Private Sub CompilerButton_Click(sender As System.Object, e As System.EventArgs) Handles CompilerButton.Click
            Dim objCodeCompiler As System.CodeDom.Compiler.ICodeCompiler = New VBCodeProvider().CreateCompiler() ' We create object of the compiler
    
            Dim objCompilerParameters As New System.CodeDom.Compiler.CompilerParameters()
            ' Add reference
            objCompilerParameters.ReferencedAssemblies.Add("System.dll")
            objCompilerParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")
            objCompilerParameters.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll")
    
            'Compile in memory
            Dim Output1 As String = "OutputApp"
            objCompilerParameters.GenerateExecutable = True
            objCompilerParameters.OutputAssembly = Output1
            objCompilerParameters.CompilerOptions = "/target:winexe"
    
            Dim strCode As String = My.Resources.TextFile1.ToString
            Dim objCompileResults As System.CodeDom.Compiler.CompilerResults = _
            objCodeCompiler.CompileAssemblyFromSource(objCompilerParameters, strCode)
    
            If objCompileResults.Errors.HasErrors Then
                ' If an error occurs
                MsgBox("Error: Line>" & objCompileResults.Errors(0).Line.ToString & ", " & _
                objCompileResults.Errors(0).ErrorText)
                Exit Sub
            End If
    
        End Sub
    

    And then in the projects resources add a text file and add the following code to it.
    This code is your application that you want to compile to a standalone EXE. And you can change it to the way you want.

    Option Strict On
    Imports System
    Imports System.Windows.Forms
    Imports System.Windows.Forms.Form
    Imports Microsoft.VisualBasic
    
    Namespace MyApp
        Public Class EntryPoint
            Public Shared Sub Main(args As [String]())
                Dim FrmMain As New Form1
                System.Windows.Forms.Application.Run(FrmMain)
            End Sub
        End Class
        Public Class Form1
            Inherits System.Windows.Forms.Form
            Private WithEvents Button1 As New Button
            Sub New()
                Application.EnableVisualStyles()
                Me.Text = "Form1"
                Button1.Text = "Click Me!"
                Button1.Top = 100
                Button1.Left = 100
                Me.Controls.Add(Button1)
            End Sub
            Private Sub Button1_Click(Sender As Object, E As EventArgs) Handles Button1.Click
                MsgBox("You Clicked Me!")
            End Sub
        End Class
    End Namespace
    

    If you have done everything above, after you click compile it should create a standalone EXE in the projects \bin\Debug under the name OutputApp.

    Again thanks to everybody.
    Hope the code above is useful to anyone who is trying to do the same thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is .NET Compact a perfect subset of .NET? Can I write a Windows Forms
How can I write an ASP.NET (C#) application that will render a page can
Can .NET (managed code) read and write to CouchDB? I would like to build
I have created a VB.NET program using windows forms. The program runs on a
I have Normal Windows Form (WinForm) C# (.Net 3.5) application, this application has label
I use C# to write windows applications with the .NET framework. How can I
i am connecting my windows forms c# .net 4 application with SQlite, as i
I might need to write some GUI application that runs on .Net (and Windows),
I'm looking to write a .Net Windows application that will capture how a user
Newbie here...can I write one program which incorporates .NET LINQ and also various Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.