Hi. New here and have question.

System_Code

Member
Joined
Jul 29, 2008
Messages
8
Programming Experience
1-3
Ok, I'm relatively new to VB.NET. I used to program in Visual Basic Script for applications (mainly with Microsoft Access) and .vbs files (which run with WinScript) before. I also do java pretty well. I just joined this bulitin board, and this is my first post. I type my code into notepad and use v3.5's vbc.exe to compile my code into executables. I was working in dos-like console applications (/t:exe) before, but now I want to focus on Windows form based applications (/t:winexe). Below is the code for my Hello World Program, on which I am having a problem I want to get resolved before continuing on to any other applications:
VB.NET:
Imports System.Windows.Forms
Module Form_Class
    Class Hello_World_Form
        Inherits Form
        Public Sub New()
            InitializeComponent()
        End Sub
        Private Sub InitializeComponent()
            Me.Text = "Hello World!"
            Me.Width = 400
            Me.Height = 500
        End Sub
    End Class
    Sub Main()
        Dim f As New Hello_World_Form
        f.Visible = True
    End Sub
End Module

It compiles fine. The problem: the form flashes on the screen for a fraction of a second, then disappears, the program stopping. Why is this happening? I'd really like to get this resolved. Thanks in advance!
 
Last edited by a moderator:
I had that problem too, and found the answer in a book somewhere awhile ago... Here is the code it used:

VB.NET:
Console.ReadLine

If you making a console application, that should work.

By the way, if you copied that directly out of your *.txt file, you have some spelling errors. i dont really know if thats important....I use VB 2008 Express Editions (free download from Microsoft, great IDE) so it takes care of most the code for me.
 
Last edited:
Sorry...

I'm trying to make a winexe. It dosen't work. By he way, thanks for telling me about the spelling errors.
 
Last edited:
As said, the IDE does most of this by default, the rest you set as properties in the Designer. When you create a new Windows Application project one empty form is already added. In Designer view you can set the Text and Size properties, you can also change the size by dragging the form the same way you size regular windows applications at runtime. There is a good reason visual designers and code editors like Visual Studio exists.
 
Run the project using Application.Run()

the form only flashes because you are not running the program as an application.
 
Ok, I'm relatively new to VB.NET. I used to program in Visual Basic Script for applications (mainly with Microsoft Access) and .vbs files (which run with WinScript) before. I also do java pretty well. I just joined this bulitin board, and this is my first post. I type my code into notepad and use v3.5's vbc.exe to compile my code into executables. I was working in dos-like console applications (/t:exe) before, but now I want to focus on Windows form based applications (/t:winexe). Below is the code for my Hello World Program, on which I am having a problem I want to get resolved before continuing on to any other applications:
VB.NET:
Imports System.Windows.Forms
Module Form_Class
    Class Hello_World_Form
        Inherits Form
        Public Sub New()
            InitializeComponent()
        End Sub
        Private Sub InitializeComponent()
            Me.Text = "Hello World!"
            Me.Width = 400
            Me.Height = 500
        End Sub
    End Class
    Sub Main()
        Dim f As New Hello_World_Form
        f.Visible = True
    End Sub
End Module

It compiles fine. The problem: the form flashes on the screen for a fraction of a second, then disappears, the program stopping. Why is this happening? I'd really like to get this resolved. Thanks in advance!
Instead of:
VB.NET:
    Sub Main()
        Dim f As New Hello_World_Form
        f.Visible = True
    End Sub
use:
VB.NET:
    Sub Main()
        Application.Run(New Hello_World_Form)
    End Sub
 
That worked. Thank you!

Same as topic. Thanks JuggaloBrotha. For whatever reason, I prefer to do all my coding in notepad rather than using the IDE. I'l see some of you arround these boards I'm sure. I have plans to create several cool programs. I might just share some of them with some of you if you're nice to me. Thanks again!
 
Back
Top