Wednesday, December 21, 2011

VB.NET: - Subroutines and functions


Subroutines and functions
Subroutines
     A subroutine is a block of statements that carries out a well-defined task. The block of statements is placed within a set of “Sub..........End Sub” statements and can be invoked by name.
Example
            Sub ShowDate()
                  MsgBox(now())
            End Sub

The above subroutine displays the current date in the massage box and can be called by its name ShowDate().
The statements in a subroutine are executed, and when the End Sub statement is reached, control return to the calling program. It’s possible to exit a subroutine prematurely with the exit sub statement.
All variables declared with in a subroutine are local to those subroutines. When the subroutine exits, all the variables declared in it cease to exit.

Functions
     A function is similar to subroutine, but a function return a result. Subroutines perform a task and don’t report anything to the calling program; functions commonly carry out calculation and report the result.
Because they return values, functions, like variable, have type (return data type). The value we pass back to calling program from a function is called return value, and its type must match the type of the function.
Function, accept arguments, just like subroutine. The statements that make up a function are placed in a set of “Function..........End Function” statement.
The result of a function is returned to the calling program with the return statement. The first time a return statement is executed. The function terminated and control is return to the calling program.
Example
      Function NextDay() as Date
            Nextday = date ADD(DateInterval.Day,1,Now())
      End Function

     Similar to variable, a custom function has a name, which must be unique in its scope. If we declare a function in a form, the function name must be unique in the form. If we declare a function as public or friend, its name must be unique in the project. Functions have the same scope rules as variables and can be prefixed by many of some keyboards. In effect, we can modify the default scope of a function with the keywords Public, Private, Protected, Friend and ProtectedFriend.

Arguments
     Subroutines and Functions aren’t entirely isolated from the rest of the application. Must procedure accept arguments from the calling program. Recall that an argument is a value we pass to procedure and on which the procedure usually act. This is how subroutines and functions communicate with the rest of an application.
     Functions also accept arguments, in many cases more than one.
Example
     The function Min(), for instance, accepts two numbers and return the smaller are :-
      Function Min(ByVal a As Integer, ByVal b As Integer) As Single
            Min=IIF(a<b;a,b)
      End Function
IFF() function is a built in function that evaluates the first argument, which is logically expression. If the expression is true, IFF() function return second argument; if the expression is False, IFF() return the third argument.

Argument passing Mechanisms
     One of the most important issues is writing procedure is the mechanism use to pass arguments. The examples so far have used the default mechanism, passing arguments by value. The other mechanism is passing them by reference.
       1. Passing argument by value:
When we pass an argument by value, the procedure sees only a copy of argument. The benefits of passing argument by value are isolated from the procedure, and only the code segment in which they are declared can change the values. This is the default argument passing mechanism in vb.net.
     To specify the argument that will by pass by value, use the ByVal keyword in front of the argument name. If we omit the ByVal keyword, the editor will insert it automatically, since it is the default option.
Example
     Function Degree(ByVal celcius As Single) As Single
            Degree= (9/5)*celcius + 32
      End Function
Note1: When we pass arguments to a procedure by reference, we’re actually passing the variable itself. Any changes made to the argument by the procedure we be permanent. When we pass arguments by value, the procedure gets a copy if the variable, which is discarded when the procedure ends. Any changes made to the argument by the procedure won’t affect the variable of the calling program.
Note2: When we pass an array as argument to a procedure, the array is always passed by reference even if we specify the ByVal keyword. The reason for this is that it would take a machine sometime to create a copy of array. Since a copy of array must also live in memory, passing too many arrays back and forth by value would depend our system’s memory.

       2. Passing Argument by Reference
Passing argument by reference gives the procedure access to actual variable. The calling procedure passes the address of the variables in memory to that the procedure can change its value permanently. With VB6.0 is the Default argument passing mechanism.
     Example
            Function ADD(ByRef num1 as Integer,ByRef num2 as Integer) As Integer
                  ADD = num1 + num2
                  num1 = 0
                  num2 = 0
            End Function
     This function adds two numbers and then sets them to zero.

VB.NET - Array

Array
     A standard structure for storing data in any programming language is the array. Array can hold set of data of the same type (a set of numbers, a series of data, and so on). An array has a name, as does a variable, and the value store in it can be access by an index.
Declaring array
     Array must be declared with the dim (or public, or private) statement followed by the name of the array and the index of the last element in the array in parentheses.
Example
     Dim arr(15) as Integer
Initializing arrays
     Just as, initializing variables, we can initialize arrays.
     Syntax: =   Dim arr_name As DataType = {entry1, entry2 ….. entry n}

Types of array
In VB.NET the array classified into following types:-
       1. One Dimensional Array: - is used to store data in one flow. At declaring time of this type of array, we use only one subscript.
Example:  Dim marks(5) as integer
In above example, we declare a one dimensional array type integer and name marks. In this, we use one subscript which size is 5.

       2. Two Dimensional Arrays: - we use two subscripts at the declaring time of this array. We separate these subscripts by comma.
Example: dim officeCount (40,5) as Byte
In the above example, we declare a two dimensional array named officeCount. In this first subscripts hold 0 to 40 and second subscript hold 0 to 5 elements. This array has total (40+1) * (5 + 1) = 246 elements.
Two dimensional arrays are also called Rectangle array.
       3. Multi Dimensional Array: - the types of array which use more than two subscripts is called multidimensional array. Visual Basic supports 32 dimensional (subscripts) in array.
Example:  Dim arr(p,q,r,s) as integer

       4. Jagged Array: - Jagged array is the combinations of many arrays. In this each array have different length. A type of array, which each element is a separate array, is called jagged array.
Example:
Dim colors(2)() as Integer
colors(0) = new string{“Red”,”Green”,”Blue”}
colors(1) = new string{“Black”,”white”}
colors(2) = new string{“Yellow”,”Gray”,”Cyan”,”Orange”}



Sunday, December 18, 2011

Maa tere doodh ka haq humse adaa kya hoga

Maa tere doodh ka haq humse adaa kya hoga

Tu jo naraz hui khush humse khuda kya hoga..
Maa tere doodh ka haq humse aada kya hoga

Yaad hai aaj bhi maa mujhko zamana mera
Mujhko School talak chodke aana tera
Sard jaadou ki khatarti hui raatou mai mujhe
Maa chupaleti thi mujhe pyar se baahou mai mujhe

Garmiyou mai mujhe anchal ki hawa deti thi
Phulne phalne ki tu mujhko duva deti thi
Raat bhar jag ke seene pe sulaya tune
Khud rahi bhuki magar mujhko khilaya tune

Tere dil jaisa kisi aur ka dil kya hoga
Maa tere doodh ka haq humse aada kya hoga
Tune aulad pe kya kuch nahi Qurbaan kiya
Apni neende humein di apna woh sukh chain diya

Log karte thai agar tujhse shikayat meri
Apni jaan par khelkar karti thi hifazat meri
Jab koi mujhko sataye tou bigadjati
Meri khatir kabhi jhagde par utar aati thi
Mere saansou mai tu moujud hai khusboo banker
Meri raatou mai chamakti hai tu jugnu banker

Tera dil todke dil mera bhala kya hoga
Maa tere doodh ka haq humse aada kya hoga
Yaad aati hai abhitak baatei teri
Mere rone se chalak jaati thi aankhein teri

Tu mujhe rota hua dekhkar rodeti thi
Apna sukh chain mere waste khodeti thi
Phir duaein mujhe de ab bhi sawar jaunga
Tu yunhi roti rahi tou mai marjunga
Hoga ehsaan gale badke lagale mujhko
Apne mamta bhare jannat mai chupale mujhko
Yahi ek raasta hai is ke siva kya hoga

Maa tere doodh ka haq humse aada kya hoga
Tujhko Allah ne kya khoob sharf baqsha
Zikar quran ke paarou mai tera aaya hai
Teri azmat ko farishtou ne i di hai
Yahi waliyou ne imamou ne gulami ki hai

Apne betou ke sitam haske uthaleti hai
Aur tu hai ke inhe phir bhi dua deti hai
Hai teri zaat pe Allah ki khudrat ko bhi naaz
Ho ijazat tou pahdhou mai tere anchal pe namaz
Martabe mai koi maa tujhse bada kya hoga

Maa tere doodh ka haq humse aada kya hoga

Wasta adam e hawa ka tujhe deta hu
Wasta shahe madina ka tujhe deta
Wasta deta hu hyder ki shujat ka tujhe
Wasta Fatima Zahra ki ibadat ka tujhe
Tu jo khush hogi tou khush honge Hussain aur Hassan
Warna veeran rahega mere jeevan ka chaman
Aye meri maa tu mera doodh na baqshegi agar
Aag douzaq ki jalayegi mujhe reh reh kar
Baad marne ke zara sonch mera kya hoga

Maa tere doodh ka haq humse aada kya hoga
:'( :'( :'(

Social Media Poetry

Great People

Thursday, December 15, 2011

Apple Products Throughout Film History*


http://dkbakrecha.webs.com/dkbstuff.htm
dkbakrecha@gmail.com

Wednesday, December 14, 2011

Create image gallary with HTML5 and CSS3.0

  


Code

<!DOCTYPE html>
<html>
<head>
    <Title>DKB Photo Gallary</Title>
   
    <style type="text/css">
        body{background-image:url(Images\bg.png);}       
       
        img
        {
        width:150px;
        height:120px;
        box-shadow:10px 10px 105px limegreen;
        border-radius:5px 5px 5px 5px;
        opacity:0.5;
        float:left;
        position:relative;
        padding:5px 5px 5px 5px;
        background:lightgreen;
        border:3px solid green;
        }
       
        .pic1
        {
        z-index:1;
        -webkit-transform:translate(50px,50px) rotate(-30deg);
        -ms-transform:translate(50px,50px) rotate(-30deg);
        -moz-transform:translate(50px,50px) rotate(-30deg);
        }
        .pic2
        {
        z-index:1;
        -webkit-transform:translate(50px,50px) rotate(-3deg);
        -ms-transform:translate(50px,50px) rotate(-3deg);
        -moz-transform:translate(50px,50px) rotate(-3deg);
        }
        .pic3
        {
        z-index:1;
        -webkit-transform:translate(50px,50px) rotate(15deg);
        -ms-transform:translate(50px,50px) rotate(15deg);
        -moz-transform:translate(50px,50px) rotate(15deg);
        }
        .pic4
        {
        z-index:1;
        -webkit-transform:translate(50px,50px) rotate(-20deg);
        -ms-transform:translate(50px,50px) rotate(-20deg);
        -moz-transform:translate(50px,50px) rotate(-20deg);
        }
   
           
        img:hover
        {
        width:400px;
        height:500px;
        box-shadow:10px 10px 105px pink;
        border-radius:5px 5px 5px 5px;
        opacity:0.5;
        float:left;
        position:relative;
        padding:10px 10px 10px 10px;
        background:yellow;
        border:3px solid orange;
        }
    </style>
</head>
<body>
    <p>
        <img class="pic1" src="Images\chloe_moretz.jpg">
        <img class="pic2" src="Images\cosmos-wide.jpg">
        <img class="pic3" src="Images\horses-wide.jpg">
        <img class="pic4" src="Images\olivia_wilde.jpg"><br>
    </p>
</body>
</html>

By Dharmendra Bakrecha
http://dkbakrecha.webs.com/dkbstuff.htm
mail : dkbakrecha@gmail.com

Work hard and Sleep Hard


Popular Posts