Sunday 23 March 2014

What Is Procedure In Visual Basic?

Procedure In Visual Basic?




Procedure:


The basic procedure are small and self-contained segments of code, which are useful for implementing the repeated task. A program, which calls the procedure is called calling program. Procedure in Visual Basic are classified into following groups.




Subroutines:


Subroutines are that type of procedure, which returns no result to the main program through which it is called. All statements of subroutines are placed within pair of Sub/End Sub statements. Subroutines are called by its name through Call statement. Syntax of Subroutines declaration is as under.

          Sub SubroutineName ([arguments])
                 Statement(s)
         [Exit Sub]
                  Statement(s)
          End Sub

Where End Sub Statement is used to send control back to main program after execution of all statements of subroutine and Exit Sub statement can be used anywhere in subroutine to send control back to main program. Subroutine name must be meaningful and not a keyword. Subroutine may have zero, one or more than one arguments.


Event Handlers:


Every application of Visual Basic contains a number of event handlers. An event handlers is like a subroutine and can be executed each time when an external condition occurs. e.g.

          Private Sub Command1_Click()
                    Statement(s)
          End Sub

This Event handler is executed when button is clicked. Unlike subroutines, Event handlers do not trnsfer control back to main program because it is called independently.


Functions:


Functions are that type of procedures, which must return a result to the calling program. All statements of a function are placed within pair of Function / End Function statements. Syntax of Function declaration declaration is.

       Function FunctionName (]arguments])[AS Data Type]
               Statement(s)
       End Function

Where Function name must be a meaningful, and not a keyword. Number of arguments in function may be zero, one or more than one. If a Function has no return Data Type then default will be Variant.



Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

Saturday 22 March 2014

What is Collection in Visual Basic?

Collection in Visual Basic



Collection:



Visual Basic provides an alternative of an array in the form of collection. In case of array elements are accessed by its index number but elements of a collection are accessed by using key that is unique for each element and also by index number. A collection is declared as

            Dim CityName As New Collection

The word New tells Visual Basic to create new collection with CityName. The object provides four methods.



Add:


Add method is used to add new item in a collection syntax of Add Method is as under 

          Collection.Add Value, Key, Beforekey, Afterkey

The argument Value represents actual item to be added in a collection and key argument represents the key for storing item. Beforekey and Afterkey arguments represents the key before or after which new item is added, but one of them can be used at a time e.g.

           CityName.Add "D.I.Khan","key2","key1"

The item 'D.I.khan' is added in the CityName collection with key "key2" and before the element of key "key1"


Remove:


Remove method is used to delete an item from collection by using an index number or key value. e.g.

                     CityName.Remove (2)                'used of index number
                     CityNameRemove ("key2")       'used of key


Item:


Using index number or a key uses, Item method to return an item of the collection e.g.

 CityName.item(1)                           'refers to first item
 CityName.item("key2")         'refers to item with key "key2"


Count:


Count method is used to return the total items of a collection. e.g.

                CityName.Count          'refers to total elements of CityName collection


Examples:

Start Visual Basic with new Standard EXE project, place a CommandButton on a Form and set the properties of controls according to the following table.


Control Name
Property
Value
Form
WindowState
2-Maximized
Command1
Caption
Enter New CityName in Collection
Command2
Caption
Count total element in Collection
Command3
Caption
Remove an item From collection
Command4
Caption
View an item of Collection
Command5
Caption
View all elements of collection
Command6
Caption
View elements of Collection by using key


Create six buttons with the upper Names.
Write the following coding in Click events of each CommanButton control and in the Load event of the Form control and in General Section.

In General Section
Dim CityName As New Collection
Dim c As Integer
Private Sub Command1_Click ()
     Dim cname As String
     Cname = InputBox (“Enter New CityName”)
      CityName.Add cname, “key” + CStir(c)
       C = c + 1
End Sub
Private Sub Command2_Click ()
Print “Total Element in CityName = “CityName.Count
End Sub
Private Sub Command3_Click ()
      On error Resum Next
       Dim index As String
       Index = InputBox (“Enter index for delete the element”
       If index < 1 0r index > CityName.Count Then
                MsgBox (“Invalid index number”)
        Else
         CityName.Remove (Val(index))
        End If
End Sub
Private Sub Command4_Click ()
      On error Resum Next
       Dim index As String
       Index = InputBox (“Enter index for print  the element”
       If index  = “” then
        Exit Sub
        End If
        If Index < 1 or index > CityName.Count Then
                MsgBox (“Invalid index number”)
        Else
         Print CityName.Remove (Val(index))
        End If
End Sub
Private Sub Command5_Click ()
    For Each cname in CityName
            Print cname
      Next
End Sub
Private Sub Command6_Click ()
      On error GoTo lab1
       Dim key As String
       key = InputBox (“Enter index for printed  the element”
       If  key  = “” then
        Exit Sub
        End If
        If  CityName.Count > 1 Then
         Print CityName.item (Key)
          Else
            Print “No Element Exist”
        End If
         Exit Sub
Lab1:
            MsgBox (“Key Not Valid”)
End Sub


Press F5 to run this project and press each CommandButton to check its output.


Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

Friday 21 March 2014

What is Array, One Dimensional Array and Two Dimensional Array in Visual Basic?

Array, One Dimensional Array and Two Dimensional Array


Array:


Array is a powerful data structure, which can hold related or unrelated data at consecutive location. In Visual Basic arrays are of one dimension or more than one dimension. But we often use one-dimensional array to present data in vector form and on two-dimensional array when we stores data in matrix form.






Declaration of One Dimensional Array:


One-Dimensional array may be declared as static or dynamic.


Static Array Declaration:


In static declaration size of array is fixed at the time of declaration of such array like.

                 Dim a(4) As Integer

Memory representation  of array "a" will be as under.

              0                                1                              2                             3                                4







Above memory representation shows that total number of elements of array "a" are 5 with lower limit 0 and upper limit 4. Like scalar variable if type of array is not defined then default type will be variant, e.g.
                   Dim b(4)

In Visual Basic index Number of first element may be other than 0. e.g.

                     Dim c(-2 To 2) As String

Memory representation of array "c" will be as under.

             -2                           -1                               0                               1                               2








Dynamic Array Declaration:


In dynamic declaration of array, size of array can be changed at any stag. Dynamic array is declared as under.

                      Dim d() As Integer

Before used of array d, you must define its scope by using Redim statement.e.g.

                        Redim d(4)

Redim is also used to change the size of array. e.g.

                       Redim d(7)

When Redim statement is used with dynamic array then data previously stored in array is lost i.e Redim statement resets all values as empty or zero.
Note that an order to avoid the loss of already stored data in array you must use the keyword Preserve with Redim statement like the following examples.

                   Redim Preserve d(7)

Example:

Start Visual Basic with a new standard EXE project and place two CommandButtons on a Form and set the Caption property of Command1 as "Used Static Array" and Caption property of Command2 as "Used Dynamic Array". and write the following code in the click events of both the CommandButton controls.


Private Sub Command1_Click()
        Dim a(4) As Integer, i As Integer
        For I = 0 To 4
              A(i) = I = 5
        Next i
        Print “Out put of static array is”
        For i = 0 To 4
              Print a(i)
        Next i
End Sub


Private Sub Command1_Click()
        Dim a() As Integer, n As Integer, m As Integer, i As Integer
         n = 3
         Redim a(n-1)
         For i = 0 To n-1
                A(i) = i + 5
          Next i
          M = 2
          Redim Preserve a (m+n-1)
          For i = n to m + n – 1
                 a(i) = i + 5
          Next i
          Print “Out put of Dynamic Array is”
          For i = 0 to m + n -1
                 Print a(i)
         Next i
End Sub


Press F5 to run the project and click the "Used of Static array" button to see the output of static array, and click the button "Used of Dynamic Array" to see the output of dynamic array.


Declaration of Two Dimensional Array:


Two-Dimensional array is declared as aunder:

         Dim a(2, 2) As Integer

This declaration of two dimensional array 'a' represent that array has three rows and three columns.

Example:

Start Visual Basic with new Standard EXE project, place a CommandButton on a Form and write following code in the Click event of the CommandButton control.

Private Sub Command1_Click()
        Dim a(2, 2) As Integer, r As Integer, c As Integer
        For r = 0 To 2
        For c = 0 To 2
              a(r, c) = r + c
        Next c, r
        For r = 0 To 2
        For c = 0 To 2
              Print a(r, c)
        Next c
        Next r
End Sub


Press F5 key to run this project and Click the Button. All the values of two-dimensional array will be displayed on the Form.


Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

Thursday 20 March 2014

How to Fix Error in PayPal during Payoneer Linking.

Fix Error in PayPal during Payoneer Linking


To withdraw your money from PayPal through Payoneer card it is necessary that you have added your Payoneer account to PayPal. But some people face problem to add their account because by adding payoneer account it shows error " We were unable to process your bank account registration at this time. We apologize for the inconvenience. Please try again at a later date " and they are unable to add their account.

I am here to sort out or fix it for you. Don't worry about it, It could be easily fixed. So follow my procedure to add your account without any error.


You have to go to your account in PayPal, In bottom you will see Contact Us. Click on it.






After clicking Contact Us you will be directed to another interface, Here you will have to click on Send Us below E-mail Us. As shown in the picture below.



Now in this interface you will see two boxes, Here you will have to choose Topic and Sub Topic of your Problem, That where you facing problem, so choose these topics according to my picture. 

Topic : Bank Account/ Credit Card
Subtopic: Bank Account - Add/Remove/Edit.




Choose 1 and 2 according to my picture above.

3. Write down four last digits of your account which payoneer give you through in e-mail.
4. Write down Simple message that you are getting an error by adding your payoneer account to paypal, and also write down the message you getting.


After filling these boxes click on Submit.

After that will get automated message from paypal system. Like i given below.



Then you will get another email from the paypal system, you will have to add your account of payoneer with in 4 hours after getting second email. 

This time your account will added successfully, Now enjoy your account and send and receive money...



Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

Tuesday 18 March 2014

How to Link Payoneer with PayPal.

To Add Payoneer with Paypal



Many countries where PayPal is not available, often they use to link their Payoneer Account which is available in most countries to withdraw their money from PayPal account through Payoneer Card.
For that Purpose you need PayPal and payoneer account, So make sure that you have these two accounts already. If not then see my post for creating account.

First you have to Login into your PayPal Account, Here you will see " Get Verified " Click on it.


Then a new Interface will open, Where they will ask for your choice to verify the account, and you have to click on bank for your verification through Payoneer. So don't click on Credit Card.

After clicking the Bank, Another Interface will open, Where you will have to check the " CHECKING " , avoid to click on saving.



Here you will see Routing number and Account Number. To Fill these boxes you need to login to your e-mail inbox and check Routing number and Account number in e-mail which is sent you by Payoneer. Note down these numbers and Put it in these boxes. Noe click on continue, After little process they will show you your bank name, you have to click it again. and then your account will add successfully. But in next 2 or 3 days they will send you small test amount  you will have to return it by putting these amount by clicking Get Verified >> confirmation.





Now you have done it successfully and you can enjoy with this service. If you facing Difficulties or getting Error message by adding your Bank Account so read my next post to fix the problem.



Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

Monday 17 March 2014

What Is If TypeOf Statement and IIf Function in Visual Basic?

If TypeOf Statement and IIf Function in Visual Basic


If TypeOf Statement:


If TypeOf Statement allows conditional execution based on processing to a control Type. Syntax of If TypeOf Statement is

If TypeOf ControlName is ControlType Then
          [StatementBlock 1]
[ElseIf TypeOf ControlName is ControlType Then
          [StatementBlock 2]
[Else
          [Statement Block n]]
End If

Where ControlName is the valid name of control and ControlType must also be valid one.



Exapmle:



Start Visual Basic with new Standard EXE project, place a CommandButton and a TextBox control on a Form and write following code in the Click event of the CommandButton.


Private Sub Command1_Click ()
      If TypeOf Text1 is Textbox Then
            Msgbox (“Textbox”)
      End If
End Sub


Press F5 key to run this project and Click the CommandButton. The result of above code will be in the Form of MsgBox function.


IIf Function:


IIf Function is closely related with If – Then – Else – structure. The syntax of IIf function is

         IIf ( Condition, Value1, Vlaue2 )

Where value1 will be returned if condition is true otherwise value2 will be returned.

Example:

Start Visual Basic with new Standard EXE project, place a CommandButton on a Form and write following code in the Click event of the CommandButton control.

Private Sub Command1_Click ()
  Dim x As Integer
  X = 6
  Print IIf ( x > 5, “ Greater then 5 “ , “Less then 5 “ )


Press F5 key to run this project and Click the CommandButton to check its output.


Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

Sunday 16 March 2014

What is Loop and its kinds in Visual Basic?

For - Next Loop, Do - Loop, While - Wend Loop and Nested Loop In Visual Basic


Loop:


Loop is used to allow the execution of one or more lines of code repeatedly for a specified number of times or according to specific condition, Visual Basic provides the following kinds of loops structures.



  • For - Next Loop Structure.
  • Do - Loop structure.
  • While - Loop structure.


For - Next Loop:


For - Next loop statement is used to repeat one statement or set of statements for specific number of times. For - Next loop is the oldest looping structure and is commonly used in all programming languages. Syntax of For - Next loop is

          For CounerVariable = startValue To EndValue [Step n]
                     [Statement(s)]
                     [Exit For]
                     [Statement(s)]
          Next [CounterVariable [, CounterVariable]...]

Description about the components of For - Next lop is

  • CounterVariable:      CounterVariable can be any numeric                                           variable, but can't be an array or record                                      Variable.
  • SartValue:                   StartValue represents the initial value of                                     counter variable that may be positive                                          or negative or zero.
  • EndValue:                   EndValue represnt the final value of                                           CounterVariable, which is used to stop                                        the execution of loop and may be positive                                    negative or zero.
  • Statements:                  One or more valid statements.
  • Step n:                        The value of CounterVariable changes in                                     the loop through step  option. If step                                             is omitted the default increment of                                               VounterVariable is 1.
  • Exit For:                     Exit For is used only in For - Next                                               statement. When Exit For is executed in                                      For - Next statement, then control is                                           transferred to the statement following to                                     the Next keyword.
  • Next:                         When Next keyword is encountered, then                                    CounterVariable is changed by                                                    value specified in Step and compared w                                      ith the final value (i.e. EndValue ). If                                           CounterVariable is not given with Next                                       statemnt, then Next keyword matches                                         the most recent For - Next statement .
It is important to note that execution of the body of this loop depends on the setting of StartValue, EndValue and Increment. If StartValue is less than EndValue then Step must used positive Values otherwise used negative values.


Example:

Start Visual Basic with new Standard EXE project, place a CommandButton on a Form and write following code in Click event of the CommandButton.

Private Sub Command1_Click ()
      Dim cv As Integer
      For cv = -3 To 2
              Print cv
      Next cv
End Sub
Output
-3
-2
-1
0
1
2

Press F5 key to run this project and Click the CommandButton. The output will be displayed on the Form as shown above.


Do - Loop:



This loop statement is used to repeat one or more statements while or until condition is True. Syntax of Do - Loop is 

Do [{while/Until} condition}       Or    Do
   [Statement(s) Block1]                   [Statement(s) Block1]
   [Exit Do]                                                  [Exit Do]
   [Statement(s) Block2]                   [Statement(s) Block2]
Loop                                   Loop [{while/Until} condition}

Description about component of So - Loop is

  • Condition:    Condition is any numeric expression that evaluates as True (Non Zero)  or False (Zero).
  • Statement(s) Block:  This statement is used in Do - Loop to transfer the control to the statement following the keyword Loop. The use of While and Until option in Do - Loop statement is optional.

Example:

Start Visual Basic with new Standard EXE project, place a CommandButton on a Form and write following code in Click event of the CommandButton.


Private Sub Command1_Click ()
      Dim I As Integer
      I = 1
       Do 
              Print I
              l = I + 1
        If I > 3 then
             Exit Do
         End If
         Loop
End Sub
Output

1
2
3




Press F5 key to run this project and Click the CommandButton. The output will be displayed on the Form as shown above. When while option is used in Do - Loop statement the body of loop will be executed till condition remains True.


While -Wend Loop:



While - Wind Loop is used to execute a single statement or a set of statements as long as specified condition remains True. The structure of While - Wend Loop is not so powerful and flexible as the structure of Do - Loop. Syntax of While - Wend loop is as under

                While Condition
                     Statement(s)
                Wend

Description about the component of While - Wend loop is as under.

  • Condition:  Condition is any numeric expression that                          evaluate as True (i.e. non Zero ) or False                          (i.e. Zero).
  • Statemants:  Statements block represents set of any                           valid statements.

Example:

Start Visual Basic with new Standard EXE project, place a CommandButton on a Form and write following code in Click event of the CommandButton.


Private Sub Command1_Click ()
      Dim I As Integer
      While I <= 3
           Print I
           I = I + 1
       Wend
End Sub
Output

1
2
3



Press F5 key to run this project and Click the CommandButton. The output will be displayed on the Form as shown above. 


Nested Loop:



When one Loop statement (i.e. For - Next loop, While - Wend or Do - Loop ) is used within the body of another loop statement then it is called loop structure. In Visual Basic nesting process can be done at many levels.


Example:


Start Visual Basic with new Standard EXE project, place a CommandButton on a Form and write following code in Click event of the CommandButton.


Private Sub Command1_Click ()
      Dim I As Integer, J As Integer
      Print “ I”, “J”
      For I = 1 To 2
          For J = 1 To 2
               Print I, J
          Next J
      Next I
      For I = 1 To 2
          For J = 1 To 2
               Print I, J
          Next
      Next
      For I = 1 To 2
          For J = 1 To 2
               Print I, J
          Next J, I
End Sub
            Output

I                               J
1                               1
1                               2
2                               1
2                               2
1                               1
1                               2
2                               1
2                               2
1                               1
1                               2
2                               1
2                               2


Press F5 key to run this project and Click the CommandButton. The output will be displayed on the Form as shown above. 


Me : If you need more help, want to ask feel free to use below comment box. It will be my pleasure to help you. THANKS for reading.

 
Search Engine Submission - AddMe url submit Casino us org Seo Packages http://blogsiteslist.com