Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

Beginning VB.NET hello world

VIEWS: 27 PAGES: 2

A slight tutorial to begin programming VB.NET using Microsoft Visual Studio 2010

More Info
									                                                       Insomnity, creativity never sleeps. A web sites about                                   SEARCH
                                                       articles, tutorials, and tips on Open Source, Design,
                                                       Programming and Technology. We also offer professional
                                                       services on web development and design, covers digital
                                                       media and printed media.




TUTORIALS


Beginning VB.NET, Hello World
by fath on May 24, 2011 • 10:52 am • Edit entry                                                                                                         No Comments




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 :

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

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




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

  1       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click                ?
  2           Label1.Text = "Hello World" & vbCrLf & "<a title="Interested ? check NETCUT ARP exploitation, how it works, how to avoid" href="
  3       End Sub

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

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

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

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




                                          http://insomnity.com/2011/beginning-vb-net-hello-world/
   7           End Sub
   8           Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   9               Label1.Text = "Hello World" & vbCrLf & "Insomnity beginning the VB.NET"
  10           End Sub
  11
  12         Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  13             Label1.Text = "What should I changed to ?"
  14         End Sub
  15     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?




What will happen if you clicked the OK button ?




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




                                                                                                                                  © 2002-2011 Insomnity. All Rights Reserved.




                                       http://insomnity.com/2011/beginning-vb-net-hello-world/

								
To top