twitter
    Find out what I'm doing, Follow Me :)

04 - Variables

Variables can hold data with corresponding data type. It can store numbers, text, and etc and is stored in the computer memory with unique addresses.

How to define a variable in VB.NET?

Dim i_can_hold_numbers As Integer
Dim i_can_hold_decimals As Decimal
Dim i_can_hold_one_character As Char
Dim i_can_hold_text As String

As you notice the first word I used Dim, it is called "Declare In Memory". It tells  the compiler that I will be creating a variable i_can_hold_numbers with type Integer after compilation, the compiler designates all variables giving them addresses for them to locate easily.

The second word is our variable name. In creating variable names, you follow a certain rules that is common to most of the programming languages.The two most important from them are,

  • You can't start the name with numbers , special characters and symbols
  • You can't use spaces between words, use "_" instead.


It is wrong to declare variables like this:
Dim i can hold numbers As Integer 

Dim 216i_can_hold_decimals As Integer

Dim @i_can_hold_numbers As Integer

Dim !i_can_hold_numbers As Integer

 - This will give you an error as stated above.

Now the last would be the variable type,  It tells the compiler the things it can hold. By the way, it's too length to post all variables here, so I'll just give you a link instead. You can find the list of variables here http://en.wikibooks.org/wiki/Visual_Basic_.NET/Variables

Adding values to the variable

For numbers:
variable_name = value   

For strings:
variable_name = "value"   

Notice that adding numeric values just only need the value itself like 23, 1000, 10.50 while strings need an opening  and closing double quote that reminds the compiler that the value is in the form of a string like "I am a string".

i_can_hold_numbers = 15
i_can_hold_text = "This is a string."

To add some information about variables, it is where you store values temporarily and is often subject for checking, especially when working with the database(Intermediate level,  will be posted soon), before taking some actions,  it is a need to verify each controls (Textbox, Button, Listview, etc.) if the contents may contain data or codes that is harmful to the database like SQL Injections.

It is also used for the default settings of the application, its window size and more.

see http://en.wikibooks.org/wiki/Visual_Basic_.NET/Variables for other declaration and assignment of value.

Now, you learned the basics of variables, we are ready to use them in our projects in the next article. See you soon. :D

Other variable declaration types other than "Dim" also known as "Access Levels"


  • Private variable_name As variable_type
  • Public variable_name As variable_type

Dim - Declare variable within the procedure, function or class.
Public - This variable is accessible in all class, procedure and functions of your project.
Private -  This variable is accessible within the procedure, function or class.


Using constants

Dump text


Next topic is about "Loop Statements".

03 - Working with our Projects with Windows Controls


Now that I've showed what a form would look like and set the location of toolbox for easy access to the list of controls available in Visual Basic.NET Express Edition. We are ready to start our development.

Exercise: We are going to create program that needs a user to input a character on a text box before it will display those typed character/s, the user needs to click the button.

Step 1. In toolbox, under Common controls, look for label. Click and drag it into the form.
Step 2. In toolbox, under Common controls, look for TextBox. Click and drag it into the form.
Step 3. In toolbox, under Common controls, look for Button. Click and drag it into the form.

It will look like these with step 1 to 3


Step 4. Double click the button, a form will display and type this:

What is a MsgBox? 
- It is a pop-up notification that will display a text.

Step 5. Click Debug > Start Debugging or you could just press F5 to compile and run.



Download the Project File:
http://www.mediafire.com/download.php?xtcwxt1356uo98s
Please scan before opening.

Move to Lesson 04 - Variables

02 - Creating new projects

To begin with our development, we will create a new project by clicking File > New Project
 like this picture:


Then another form will display for selecting a type of project you're going to use,
 choose Windows Form Application then click OK


Now we are ready for development, you'll notice that a square shaped object is displayed in the left corner of the screen with three buttons in upper right edge, it is where we will work most of the time. It is called Windows Form or just Form. By the way, I added a label for you to locate the form.


Click ToolBox, Then click "Auto-Hide" to display it without hiding.


Move to Lesson 03 - Working with our Projects with Windows Controls

01 - Downloading Visual Basic.NET

Downloading Visual Basic.NET


To start our adventure, I'll give you links for what we would need as we develop programs. In most cases, VB 2010 Express Edition is what we'll use 'cause it's free if don't have enough money to buy premium edition. Express Editions are enough to work the job disregarding reports and other features which were removed.

List of vb.NET installers depending on your processor's speed :


If you have faster processor speed, you can download Visual Basic 2010 Express Edition.

If you have a slower processor speed, you can download Visual Basic 2008 Express Edition.
Scroll down and look for "Visual Basic 2008 Express Edition with SP1",  then choose your language and click"Free Download"


But still it doesn't matter of what version you will install 'cause what we will do in our journey covers the basics of VB.NET, it a step in developing larger application. Coding is available to both editions although we can observe slight changes in coding, but don't worry, you can post here and I'll try best to answer all of  your questions. :D

Move to Lesson 02 - Creating new projects

Another chapter of the blog begins

As time passes by, I try to discover new things out of something what I have. I realize the content of this blog focuses in just one subject  "Music" to help this blog grow, I'll add programming tutorials for VB.NET 2010.
I'll post up a step by step tutorial for beginners and intermediate level and try my best to make it easy to understand and apply.

It encompasses subjects such as basic manipulation of controls like Textbox, Label and etc. to manipulation of data from the database using R/DBMS like Microsoft Access, Microsoft SQL Server, MySQL and etc.

Are you ready for a change? :D

Other programming languages will be posted soon.
Last year, I plan to create a simple song or just a cover for someone. So I come up with an idea of making one when I watched Summertime's end video of his version of "happy birthday" then I started producing...

Later in my production when I try to insert vocals, it didn't went well maybe due to the microphone (there's lots of hiss and sounded so dull and muddy). I realize what's the sense of making this song if the production and vocals weren't special that would fit for that day of her birthday? , So I stopped. Maybe if I got a decent mic, i'll grab that chance again. :D

But you can still listen it here:


 
  Bajongskie - Happy Birthday (Instrumental) by Bajongskie [DEMO]

Wondered how to sing this song? It's from Summertime's End - Happy Birthday, Jacquie

Hello Seattle (REMAKE) [FL Studio 9]

Last saturday, I just finished my cover of Hello Seattle by Owl City. At first it's frustrating because of the drum fills, it's kinda tricky but atleast It's finish with a little touch of my style. Hope you like it. :)

PS:
Starter's mistakes about vocals. Yay!, It overlaps frequency which I realize while listening it a year after. haha..

In Christ alone

It's nice to hear that one of my favorite music artist Adam Young created a cover of a religious song named "In Christ alone" and "How deep the father's love" which he posted on his blog last November. It really makes me closer to God again. The first song is a piano accompaniment and the other is somewhat an electro-acoustic. :) Download link are posted below " Right click -> Save Target As "

Here it is:



Lyrics:                                                                                                                                                     
 Key : Eb                                                                                                                                                  

 Verse: (Ab, Eb, Ab, Bb)
 In Christ alone, my hope is found
 He is my light, my strength, my song
 This cornerstone, this solid ground
 Firm through the fiercest drought and storm
 What heights of love, what depths of peace
 When fears are stilled, when strivings cease
 My comforter, my all-in-all
 Here in the love of Christ I stand

Key: F

 Verse: (Bb, F, Bb, C)
 There in the ground His body lay
 Light of the world by darkness slain
 Then bursting forth in glorious day
 Up from the grave He rose again
 And as He stands in victory
 Sin's curse has lost its grip on me
 For I am His and He is mine
 Bought with the precious blood of Christ

Key: G

 Verse: (C, G, C D)
 No guilt in life, no fear in death
 This is the power of Christ in me
 From life's first cry to final breath
 Jesus commands my destiny
 No power of hell, no scheme of man
 Can ever pluck me from His hand
 Till He returns or calls me home
 Here in the power of Christ I'll stand

 Till He returns or calls me home
 Here in the power of Christ I'll stand.

Chords from Bajongskie. :)

How Deep The Father's Love




Download Link:


Port Blue - Up Ship ( Song cover)



A cover I created few months ago, it somewhat crappy but I hope you'll still like it. I'll gonna' make my another song or cover better next time. :)

Stepped out in my dream (Ambient)



The song is made in the key of B. It's more of like a loneliness that plays in my mind that time. Instruments used are String, acoustic guitar, bass and piano.

Though there were slight technical problems you may find while listening esp. the piano which isn't in time but I hope that wouldn't let you stop from listening it.

Genre: Ambient
 :)