Monday, December 28, 2009

Writing and Compiling in Visual Basic

To compile use the command below

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe code.vb

Sample 1 (Console)
Module Tester

Sub Main()
Console.Write("Welcome to ")
Console.WriteLine("Visual Basic!")
End Sub ' Main

End Module

Sample 2 (GUI)
Imports System
Imports System.Windows.Forms

Class MyFirstForm
Inherits Form

Private WithEvents mybutton As Button

Public Sub New()
Me.Text = "Hello, WinForms!"
mybutton = New Button()
mybutton.Text = "Click Me!"
End Sub

Public Sub mybutton_Click(sender As Object, e As EventArgs) Handles mybutton.Click
End Sub

End Class

Class MyFirstApp
Shared Sub Main()
Dim myform As Form = New MyFirstForm()
End Sub
End Class

No comments: