Showing posts with label Types of Variable. Show all posts
Showing posts with label Types of Variable. Show all posts

Monday, July 23, 2012


Types of Variables:

Data Types: 
       Programming मे data types Data का type define करते हैं। Data types store होने वाले data के type के साथ ही उसकी data storage length भी बताते है। Visual Basic मे variables को निम्नलिखित पाँच categories मे बांटा गया है।
  • Numeric
  • String
  • Boolean
  • Date
  • Object

1.     Numeric Variables: इसमे numbers store करने वाले data type आते हैं। इनका प्रयोग mathematical operations perform करने के लिए किया जाता है। इसमे निम्न data type’s आते हैं-

Ø  Short (Int16): यह integer value को स्टोर करने लिए use होता है। इसमे -32768 से 32767 तक value store की जा सकती है और यह memory मे 2 bytes लेती है।

                        Dim a As Short
                      a = 10000

Ø  Integer (Int32): यह integer value को स्टोर करने लिए use होता है। इसमे -2147483648 से 2147483647 तक value store की जा सकती है और यह memory मे 4 bytes लेती है।
Dim a As Integer
a = 1000000

Ø  Long (Int64): यह integer value को स्टोर करने लिए use होता है। इसमे integer से बहुत अधिक value store की जा सकती है और यह memory मे 8 bytes लेती है।

Ø  Single: यह single precision floating no को स्टोर करता है। इसमे -3.402823E38 से -1.401298E-45 और 1.401298E-45 से 3.402823E38 तक value store कर सकता है। यह 4 byte memory लेता है।

Ø  Double: यह double precision floating no को स्टोर करता है। इसमे -1.797693134486232E308 से -4.94065645841247E-324 और 4.94065645841247E-324 से 1.797693134486232E308 तक value store कर सकता है। यह 8 byte memory लेता है।

Ø  Decimal: इसमे 0 से 7.9228162514264337593543950335  positive और negative value store कर सकते हैं। यह memory मे 16 Byte लेता है।

Ø  Byte: यह भी एक numeric data type है जो की 0 से 255 तक की value store की जाती है। यह memory मे 2 byte लेता है।

2.     String: यह characters को store करने के लिए प्रयोग होता है। इसमे निम्न 2 type होते हैं।

1.     String: यह केवल text को store करने के लिए use किया जाता है। यह set of characters को स्टोर करता है। इसमे 2 GB तक text store कर सकते है।

2.     Char :  यह single character को store करने के लिए use होता है। और memory मे 2 byte memory लेता है।

3.     Boolean: इस data type का प्रयोग True या false value store करने के लिए किया जाता है। यह conditions check करने मे अधिकतर प्रयोग होता है।

4.     Date: यह data type date और time store करने के लिए प्रयोग किया जाता है। इसमे date या time को store करने के लिए # कैरक्टर का प्रयोग करते है।

Dim a As Date
a = #1/4/2005#

5.     Object: यह एक common data type है जो की सभी data types के common features के साथ सभी प्रकार की value store करने के लिए use किया जाता है। 


Variables:

            Computer programming मे variables बहुत महत्वपूर्ण स्थान रखते हैं। variables, named locations जिनका प्रयोग किसी value को store करने के लिए किया जाता है। प्रत्येक variable का एक नाम और value होती है साथ ही इसका एक Type होता है। visual basic मे कई प्रकार के Data Types होते हैं। जैसे – Integer, String, Date, Char, Decimal etc.

Declaring Variables:

       Visual Basic.Net मे variable को declare करने के लिए Dim statement का प्रयोग किया जाता है। जिसका Syntax निम्नलिखित हैं।

Dim <Variable Name> As <Data Type>
जैसे
 Dim name As String

इस statement मे Dim keyword variable का dimension, variable name के साथन पर variable का नाम, As keyword और data Type बताता है। Visual Basic.Net मे साधारणतया variables इसी प्रकार से declare किए जाते हैं। इसके अलावा scope के अनुसार variable declaration statement बदल जाती है। public variable declare करने के लिए public keyword का प्रयोग Dim के स्थान पर किया जाता है।

Public <Variable Name> As <Data Type>

इसी प्रकार private और friend keyword भी variable declare करने के लिए प्रयोग किए जाते हैं। private, public, protected और friend variable के scope के लिए प्रयोग होते हैं। VB.Net मे multiple variables को single statement मे declare किया जा सकता है।

Dim a, b, c as Integer

इसी प्रकार इसमे multiple type के variables को भी single dim statement मे declare किया जा सकता है।

Dim a As Integer, name As String, b As Boolean

Variable Naming Conventions:

·         Variable का नाम हमेशा letter से शुरु होता है।

·         Variable name हमेशा 255 character से ज्यादा नहीं होता चाहिए।

·         Variable name मे numbers और underscore को छोडकर किसी अन्य character का प्रयोग नहीं किया जाता है।

·         Variable name  हमेशा अपने scope मे unique होना चाहिए।

·         Visual Basic के keywords को Variable name मे use नहीं किया जा सकता है।

·         Variable name मे blank space नहीं होना चाहिये । 

Contact us

Name

Email *

Message *