LOG IN

Forgot Your Password?


Incorrect login or password

SIGN UP



Existing user?

Forgot Password


Existing user?

VB .NET

VB.NET:

Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
    Close()
End Sub

The 'cmd' prefix is replaced by the 'btn' prefix, conforming to the new convention previously mentioned.[which?]

Visual Basic 6 did not provide common operator shortcuts. The following are equivalent:

Visual Basic 6:

Sub Timer1_Timer()
    'Reduces Form Height by one pixel per tick
    Me.Height = Me.Height - 1
End Sub

VB.NET:

Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Me.Height -= 1
End Sub

Comparison with C Sharp/C#
Main article: Comparison of C Sharp and Visual Basic .NET

C# and Visual Basic .NET are Microsoft's first languages made to program on the .NET Framework (later adding F# and more and others have also added languages). Though C# and VB.NET are syntactically different, that is where the differences mostly end. Microsoft developed both of these languages to be part of the same .NET Framework development platform. They are both developed, managed, and supported by the same language development team at Microsoft.[8] They compile to the same intermediate language (IL), which runs against the same .NET Framework runtime libraries.[9] Although there are some differences in the programming constructs, their differences are primarily syntactic and, assuming one avoids the Visual Basic "Compatibility" libraries provided by Microsoft to aid conversion from Visual Basic 6, almost every command in VB has an equivalent command in C# and vice versa. Lastly, both languages reference the same Base Classes of the .NET Framework to extend their functionality. As a result, with few exceptions, a program written in either language can be run through a simple syntax converter to translate to the other. There are many open source and commercially available products for this task.
Examples
Hello world!
Windows Form Application

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Hello world!", MsgBoxStyle.Information, "Hello world!") ' Show a message that says "Hello world!".
    End Sub

End Class

Hello world! window
Console Application

Module Module1

    Sub Main()
        Console.WriteLine("Hello world!") ' Write in the console "Hello world!" and start a new line.
        Console.ReadKey() ' The user must press any key before the application ends.
        End ' End the application.
    End Sub
End Module

Speakering
Windows Form Application

Public Class Form1
   
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim Voice = CreateObject("Sapi.Spvoice")
        Dim Text As String = TextBox1.Text
        Voice.Speak(Text)
    End Sub
   
End Class

Console Application

Module Module1
    Private Voice = CreateObject("Sapi.Spvoice")
    Private Text As String

    Sub Main()
        Console.Write("Enter the text to speak: ") ' Say "Enter the text to speak: "
        Text = Console.ReadLine() ' The user must enter the text to speak.
        Voice.Speak(Text) ' Speak the text the user has ent

ered.
    End Sub
End Module

Source: https://en.wikipedia.org/wiki/Visual_Basic_.NET


 << Previous  Next >>