What is Variables

Variables

किसी भी प्रकार के Data को Process करने के लिए हमें सबसे पहले ये तय करना होता है, कि हम किस प्रकार के Data को Computer की Memory में Store करना चाहते हैं, क्योंकि जब तक हम Process किए जाने वाले Data को Computer की Memory में Store नहीं कर देते हैं, तब तक हम उस Data को Process नहीं कर सकते हैं।

चूंकि अलग-अलग प्रकार के Data Memory में अलग-अलग Size की Space Reserve करते हैं, इसलिए जब हमें Process किए जाने वाले Data के Type का पता चल जाता है, तब हम उस Data Type को Represent करने वाले Keyword के आधार पर Memory में कुछ Space Reserve करते हैं और उस Space का कोई नाम Assign करते हैं। ये नाम उस Reserved Memory Location का एक Symbolic Identifier होता है, जो कि Identifier Naming Convention के नियमों के आधार पर तय किया जाता है।

Program की जरूरत के आधार पर किसी Data को Store करने के लिए Computer की Memory में Space Reserve करने व उस Space का कोई Symbolic नाम देने की प्रक्रिया को Identifier Declaration कहते हैं।

यदि Define किए जाने वाले Identifier का मान पूरे Program में स्थिर रहे, तो इस प्रक्रिया को Constant Declaration कहते हैं, जबकि यदि Define किए जाने वाले Identifier का मान पूरे Program में समय-समय पर Program की जरूरत के आधार पर बदलता रहे, तो इसे Variable Declaration कहते हैं।

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निम्नलिखित हैं।

Syntax: Dim <Variable Name> As <Data Type>
Example: 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 किया जा सकता है।Example: Dim a, b, c as Integer

इसी प्रकार इसमे multiple type के variables को भी single dim statement मे declare किया जा सकता है।Example: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 नहीं होना चाहिये ।

 


error: Content is protected !!