This tutorial is just a simple introduction on VB.Net programming, when you’re a seasoned VB programmer, trust me, you don’t want to read this whole post, it would be frantically boring.

Why VB.Net ? well since I just learned VB.Net, I’ll make my own record on what I’ve learned here. I hope some of you wanted more so I can try harder and share a more complex program :) For this purposes, I will use Microsoft Visual Studio 2010 Express, a free IDE to play around with VB.Net

Lets create a New Project, get to the menu, then choose File > New > Projects. There will be a dialog windows, choose Visual Basic > Windows Forms Application, don’t forget to set a directory for the projects and a name. For now, lets call it “HelloWorld“.

You will then get a form and a workspace in front of you, should be Form1. Double click the form, then the script editor will come out, and make sure the script will looks like this :

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Hello World"
        Label1.Text = "What should I changed to ?"
        Button1.Text = "OK"
        Button2.Text = "Clear"
    End Sub
End Class

Now back to the visual designer, add 1 label and 2 buttons so it will looked like this :

vbnet-helloworld-001

Double click Button1, and you will get script editor again for button1. Now change the new generated script like below :

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = "Hello World" & vbCrLf & "<a title="Interested ? check NETCUT ARP exploitation, how it works, how to avoid" href="http://insomnity.com/2011/netcut-arp-exploitation/">Insomnity</a> beginning the VB.NET"
    End Sub

Back to the visual editor, now double click the second button, Button2, the script will be like below :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Label1.Text = "What should I changed to ?"
    End Sub

Okay, you’re done, the final code will be as below :

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "Hello World"
        Label1.Text = "What should I changed to ?"
        Button1.Text = "OK"
        Button2.Text = "Clear"
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = "Hello World" & vbCrLf & "Insomnity beginning the VB.NET"
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Label1.Text = "What should I changed to ?"
    End Sub
End Class

Explanation:

When you double click an element in the visual editor, you will automatically brought to the script editor for the corresponding elements, this gives out the ease to know which to edit immediately. Furthermore, pay attention to the handles, the handles for button and your main form are different. MyBase.Load means that the script will be executed during first load of the program, while Button1.Click means the script will be executed when the button clicked.

Me.Text gives the title to the form.
The Label1.Text gives a command to set the text that will be displayed on Label1.
Button1.Text gives what should be displayed on Button.1.
Button2.Text gives what should be displayed on Button.1.

Now press F5 button to see your first application. Click between Ok and Clear button to see the program in action. Now you should understand what the script are doing, shouldn’t you?

vbnet-helloworld-002

What will happen if you clicked the OK button ?

vbnet-helloworld-003

 

On this Beginning VB.NET, Hello World post, I just give you a simple example on how basic things works on VB.Net. I hope you enjoyed this and want more. Again, I’m open to any comments and suggestions

Incoming search terms:

  • vb net hello world
  • vb net for dummies
  • Mail insomnity
  • visual script editor
  • vb net me text
  • vb net arp
  • vb net boring
  • vb net clear label1 text
  • bilder für buttons vb net
  • vb2010 sender form