Hi, this is the first post where I am going to give a brief
introduction on VB.Net and how to start learning it. If you know any of the
programming basics or good at logic and make use of existing resources then you
are at the right place to gain all the knowledge.
Creating First Project in VS 2010
Note: The button size might not be sufficient to hold the Button Text as “Say !! Hellow” increase the button width and should work. Also for the form can be decreased.
The above code is generated by default. We shall discuss on each of them in
details in later posts. As of now let us just add the required functionality.
All the posts in the series would use Microsoft Visual
Studio 2010 (VS 2010) to demonstrate the VB.Net.
Creating First Project in VS 2010
1.
Open Microsoft VS 2010
2.
Goto File->New
Project (Ctrl + N shortcut)
3.
Select Windows
on the left pane and Project type as Windows
Forms Application from middle
pane. At the bottom of the Window Name: WindowsApplication1
is given by default change it to MYFirstProject
and click on Ok.
4.
Now the screen should be showing the below the
Form Form1.vb is created by default by VS and the solution Explorer shows the
project files such as all the VB files, forms etc
5.
Now let us Debug the project created. Go to Debug -> Start Debugging (F5
shortcut). And the below window
should pop up.
6. Next
would be changing the Form name and Form Title. To do this we need to change
the property of the Form. The
Property of any object in VB.Net can be changed in two ways one is by changing
the property from properties window and other by changing the property from
code. Both are equally helpful and would need understanding on how to use and
when to use.
The Properties
window shows the various properties that an object supports. Let us
understand few of them
a. Name: specifies the name of the
Object.
b. Text: this property is to give the display value
for the object. For a form it would be the Title and for a Button it would be
a Button name and so on.
c. Font : this property is to change the font type.
d. ForeColor: this property is to change
the color of the text.
e. BackColor: this property is to change
the background color of the object.
f. Enabled: this property is used to
Enable or Disable the Object
g. StartPosition: this property is used
to set the start position of the Form. Like the form should at the center of
the screen, bottom right etc.
There are still a lot of properties that we will
be using let use discuss on them when we come across.
|
7.
Let us change the Form name from Form1 to MyFirstForm and Form Text from Form1
to Hellow Form.
8.
Let us add the first control on the Form MyFirstForm. From the ToolBox click on Button and drag the Button on the Form
and place it somewhere on the form.
9.
Let us rename the Button name and Button text.
Select the Button on the Form and go to Properties window. And change the
Button Name property to HellowButton
and Button Text to Say !! Hellow .
The form should as below now
Note: The button size might not be sufficient to hold the Button Text as “Say !! Hellow” increase the button width and should work. Also for the form can be decreased.
10.
Now that we have added a button on the form let
us assign functionality to the form. When we click on the Button then a popup
should come up saying “Hellow”. To do this double click on the Button and it
should take to you to the code screen of Form1
Add the below lines of code before End Sub.
11.
Now let us debug the code by pressing F5 and
click on Say !! Hellow Button
12.
Congrats we just completed our first VB.Net
Project. Stay tuned for more.