Home •  
It is currently Fri Sep 03, 2010 12:33 am

All times are UTC


Forum rules


Please click here to view the forum rules



 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: Visual Basic dot NET - Tutorial
PostPosted: Sun Feb 18, 2007 10:49 pm 
Offline
Retired Moderator
Retired Moderator

Member ID #: 98
Joined: Sat Feb 03, 2007 11:30 am
Posts: 337
Location: Germany
@Thoosje: Here we go.. :D

This tutorial will explain you the main things you should know about vb.net and how to handle the editor. Lets start with the apps Thoosje explains in his vbscript tutorial :)
The good thing is that both languages are pretty similar!

[url=http://msdn.microsoft.com/vstudio/express/vb/download/]First of all you should download the vb.net express suite (note: its completely free and does not expire)
[/url]
If it asks you to install MSDN, then you should do it. It contains much examples which will help you to write your own applications.


Application 1 - Message Box

Now open vb.net express and go to File -> New Project.
Choose "Windows Application", give it a name and press OK.

The window should be divided into 3 sections now. At the left is the toolbox where you can choose objects to use with your app.
In the middle of the screen is the preview of your application and on the right is the properities window for the Form and the objects.

Doubleclick the form in the middle of your screen so that the code editor appears.

Copy&Paste that between your "Private Sub ....." and "End Sub" section [that section is executed when the app is started]

Code:
MsgBox("I am a Message Box, blop")


You should have something like this:

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs)
    Handles MyBase.Load

    MsgBox("I am a Message Box, blop")

    End Sub
End Class


Now click the green arrow on the top which starts Debug Mode and runs your application. Congratulations, you just have written your first vb.net app :D


Application 2 - The funny stuff

This is going to be an app that can talk with you :wink:

Start a new project and choose "TextBox" from your toolbox on the left. Then click on the form to place the textbox.
Now do the same with "Label" and place it over the textbox. As next click the label once and scroll down at the Properities window (on the right) until you see the field named "Text".
Enter there: "Your Name:"

Now place choose "Button" from the toolbox and place it under the textbox. Again you can give it a Name like "Continue".
.. Voila !

You can move and resize the objects and also the form so everything fits.


Doubleclick the button to open the editor. [This section is executed when the button is pressed]

Copy&Paste the following code into that section:

Code:
        Dim name As String = TextBox1.Text

        MsgBox("I'm a magician, I know your name...")
        MsgBox("You are " & name & " !!!")


"Dim name As String" defines a new variable named "name" and assigns the type String. It is equal to the text from the textbox you type your name in later.
It is important you write the variable name without " " in the MsgBox( ) so it is treated like a variable. All simple text is enclosed in " ".


It should look like this:

Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Handles Button1.Click

        Dim name As String = TextBox1.Text

        MsgBox("I'm a magician, I know your name...")
        MsgBox("You are " & name & " !!!")
    End Sub
End Class


Press the green arrow to test your application now.

If you want to compile this magic app and have it as an .exe or just to send it to some friends, then click "Build" -> "Build 'appname' " on the top. The executable is in your project folder which is usually at "My Documents\Visual Studio 2005\Projects\YourProject\bin\Release

Note: Your friends will need Microsoft Framework v2 to run the programs compiled with vb.net.



More to come soon!


 Profile  
 
 Post subject:
PostPosted: Sun Feb 18, 2007 11:23 pm 
Offline
Administrator
Administrator
User avatar

Member ID #: 3
Joined: Wed Jan 17, 2007 11:49 pm
Posts: 2019
Location: Friesland
OMG lol i wil post some vb.net stuff to soon lol



_________________
Image
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: