Saturday, March 10, 2012

The basic

2. The basics
Now we are going to learn the basic of the Visual Basic programming
Today we will use :
  • Button
  • PictureBox
  • TextBox and 
  • Label


2.1 OK, lets start by adding a textbox, a label and a button to our project new project.


Try to make the form like this.
Change the label text to blank.






Textbox - here we will enter our name
Button - after we push the button the label text will change "Welcome MyName.How are you today?"
Label - it will show the text

Code:

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If Not TextBox1.Text = "" Then
            Label1.Text = "Welcome " & TextBox1.Text & ". How are you today?"
        Else
            Label1.Text = "Please enter your name."
        End If
    End Sub

'The IF event will check did we wrote our name or we left it blank if we left it blank the label text will change to 
"Please enter your name", if we wrote our name label text will change to ex. "Welcome Gabriel.How are you today?"

Case 1 - If we write our name 


Case 2 - If we don't write our name



2.2 In the same project add a picturebox (resize the form if needed)
After we placed our picture box we will add a picture to it. Click on the picture box, go to properties, and click the where it says "Image". Press the "..." and select any picture you want. 

And that is it, easy right? Hope you learned something. =)




Tuesday, March 6, 2012

How to start programing in visal basic 2010

Introduction

Visual Basic is a free set of tools that windows developers at any level can use to create they're custom application using basic and expert settings.

1.Creating our first application

Before creating a new application we need to make a new project, you need to click and select new project
New project dialog will appear :

The dialog box offers you seven types of projects that you can create. As we are going to learn to create windows applications, we will select "Windows Forms Application".
At the bottom of this dialog box, you can change the project name (default "WindowsApplication1") to some other name you like, for exampe, MyFirstProgram. After you have renamed the project of your liking, click "OK" to continue. The following Windows will appear. It consists of an empty form, the common controls toolbox, the solution explorer and the properties.
Now we will create or first program, lets add 1 button and change the text of it "Properties window-Text" and change what every you like ex. "Message box"

Now for the coding part we will make that when you push the button it will show you a messagebox notification.
Double click the button and key in the following code at the source code window as show below.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("This is my first application :]")
End Sub


Now run your first application. After you pushed the button you can see the messge poping out
with the worked we writed before.
Today we learned how to make a message box. I hope you enjoyed the tutorial. :]