Visual Basic for Application (VBA) Introduction - Chapter 1

Visual Basic for Application (VBA) is a computer programming language that helps to create the macros with the help of Coding in most commonly used Microsoft Office Applications e.g.; Microsoft Word, Microsoft Excel and Microsoft PowerPoint & other Ms Office applications.

وژوئل بیسک فار ایپلی کیشن (وی بی اے) ایک کمپیوٹر پروگرامنگ زبان ہے جو عام طور پر عام طور پر استعمال ہونے والے مائیکروسافٹ آفس ایپلیکیشنز جیسے کوڈنگ کی مدد سے میکرو کو بنانے میں مدد کرتی ہے۔ مائیکروسافٹ ورڈ ، مائیکروسافٹ ایکسل اور مائیکروسافٹ پاورپوائنٹ اور دیگر محترمہ آفس ایپلی کیشنز۔

In this Article, we’ll learn how to create the macros by using Visual Basic for Applications (VBA) coding in MS Excel to automate tasks. Before starting this article, let’s have a brief introduction about the main components in VBA Coding listed as follows:

اس آرٹیکل میں ، ہم سیکھیں گے کہ ایم ایس ایکسل میں ویژویل بیسک فار ایپلی کیشنز (وی بی اے) کوڈنگ کے ذریعے کاموں کو خود کار بنانے کے لئے میکرو کو کیسے تیار کیا جائے۔ اس مضمون کو شروع کرنے سے پہلے آئیے VBA کوڈنگ میں درج ذیل اہم اجزاء کے بارے میں ایک مختصر تعارف پیش کرتے ہیں۔


  • Create a Macro.
  • MsgBox
  • Workbook and Worksheet Object
  • Range Object
  • Variables
  • If Then Statement
  • Loop
  • Macro errors
  • String Manipulation
  • Date & Time
  • Events
  • Array
  • Function and Sub
  • Application Object
  • ActiveX Controls
  • User forms

1. Create a Macro:

Macro is an technique in Visual Basic for Applications (VBA) to make the task automate in Excel. There are further two types of Macro Creation:

میکرو ایکسل میں ٹاسک کو خودکار بنانے کے لئے ایپلیکیشنز (وی بی اے) کے لئے وژوئل بیسک میں ایک تکنیک ہے۔ میکرو تخلیق کی مزید دو قسمیں ہیں:

  • Writing a code.
  • Recording macro.


2. MsgBox:

In Visual Basic for Application, msgbox is commonly known as the dialogue box which is used to sharing some information or data with the user of Program.

وژوئل بیسک فار ایپلی کیشن میں ، msgbox عام طور پر ڈائیلاگ باکس کے نام سے جانا جاتا ہے جو پروگرام کے صارف کے ساتھ کچھ معلومات یا ڈیٹا کا اشتراک کرنے کے لئے استعمال ہوتا ہے۔



3. Workbook and Worksheet:

In Visual Basic for Application, Workbook referred as the file in which you are currently working or have opened. Each Workbook has multiple collections of Worksheets. For each worksheet, there is an entry or data in this collection. This collection is commonly known as worksheets. There are multiple worksheets in a workbook having multiples entries.

وژوئل بیسک فار ایپلی کیشن میں ، ورک بک کو اس فائل کے طور پر حوالہ دیا جاتا ہے جس میں آپ فی الحال کام کر رہے ہیں یا کھولی ہے۔ ہر ورک بک میں ورک شیٹس کے متعدد مجموعے ہوتے ہیں۔ ہر ورک شیٹ کے ل this ، اس مجموعہ میں ایک اندراج یا ڈیٹا موجود ہے۔ یہ مجموعہ عام طور پر ورک شیٹ کے نام سے جانا جاتا ہے۔ ایک ورک بک میں متعدد اندراجات والی ایک سے زیادہ ورک شیٹس ہیں۔



4. Range Object:

In Visual Basic for Application, Range Object is the representation of a cell, a row, a column, a selection of cells containing one or more contiguous blocks of cells, is the most important object in Excel VBA.

وژوئل بیسک فار ایپلی کیشن میں ، رینج آبجیکٹ ایک سیل ، ایک قطار ، ایک کالم ، خلیوں کا انتخاب ہے جس میں خلیوں کے ایک یا زیادہ پیچیدہ بلاکس ہوتے ہیں ، ایکسل وی بی اے میں سب سے اہم شے ہیں۔


5. Variables:

Variables are generally known as specific values stored in the memory of computer or storage system. In Visual Basic for Application (VBA), we create different variables to store values. Later, we can use that values in code and execute. In VBA, we defined the variable with a different and specific name.

متغیرات عام طور پر کمپیوٹر یا اسٹوریج سسٹم کی میموری میں ذخیرہ شدہ مخصوص اقدار کے طور پر جانے جاتے ہیں۔ وژوئل بیسک فار ایپلی کیشن (VBA) میں ، ہم قدروں کو ذخیرہ کرنے کے لئے مختلف متغیرات تخلیق کرتے ہیں۔ بعد میں ، ہم اس اقدار کو کوڈ میں استعمال کرسکتے ہیں اور اس پر عملدرآمد کرسکتے ہیں۔ وی بی اے میں ، ہم نے متغیر کی وضاحت مختلف اور مخصوص نام کے ساتھ کی۔




6. If Then Statement:

In Microsoft VBA, if Then Statement or IF Then Else Statement are used to execute one set of code if specified condition evaluates to TRUE, and another set of code if that specified condition evaluates to FALSE. Furthermore, IF THEN ELSE STATEMENT is also categorized as a built-in Logical Function in Excel.

مائیکروسافٹ VBA میں ، اگر پھر بیان یا IF پھر دوسرے بیان کو کوڈ کے ایک سیٹ پر عمل درآمد کرنے کے لئے استعمال کیا جاتا ہے اگر مخصوص حالت کی درستی کا اندازہ ہوتا ہے ، اور کوڈ کا دوسرا مجموعہ اگر اس مخصوص حالت FALSE کا اندازہ کرتا ہے۔ مزید برآں ، اگر پھر ELSE بیان بھی ایکسل میں بلٹ ان منطقی تقریب کے طور پر درجہ بندی کیا گیا ہے۔



7. Loop:

In Excel Visual Basic for Applications (VBA), loop is an important part/tools used in the VBA programming language. With the help of this loop tool, user can repeat the same action or code block  multiples times in a worksheet until loop function attained the specific point or given condition. After attaining the given condition, the program executes the next code block.  

ایکسل بصری بنیادی برائے ایپلی کیشنز (VBA) میں ، لوپ ایک اہم حصہ / ٹولز ہے جو VBA پروگرامنگ زبان میں استعمال ہوتا ہے۔ اس لوپ ٹول کی مدد سے ، صارف ورکی شیٹ میں ایک ہی عمل یا کوڈ بلاک کو متعدد بار دہرا سکتا ہے جب تک کہ لوپ فنکشن مخصوص نقطہ یا دی گئی حالت کو حاصل نہ کرے۔ دی گئی شرط کو حاصل کرنے کے بعد ، پروگرام اگلے کوڈ بلاک پر عمل درآمد کرتا ہے۔



8. Macro Errors:

Macro Error is an error type in Visual Basic for Application (VBA). It appears when we are running a macro in VBA that contains an error. Error Message tell us that specific highlighted line has an execution error.  

وژو بیسک فار ایپلی کیشن (VBA) میں میکرو خرابی ایک غلطی کی نوع ہے۔ ایسا ہوتا ہے جب ہم VBA میں میکرو چلا رہے ہیں جس میں ایک خرابی ہے۔ غلطی پیغام ہمیں بتائیں کہ مخصوص روشنی ڈالی گئی لائن میں عملدرآمد میں خرابی ہے۔




9. String Manipulation:

In Visual basic for Applications, String Manipulation is an important part in VBA programming language for Macro Programming and String Operations, Left Side String Manipulation, Right Side String Manipulation, Mid String Manipulation.

وژوئل بیسک فار ایپلی کیشنز میں ، میکرو پروگرامنگ اور سٹرنگ آپریشنز ، بائیں بازو کے اسٹرنگ ہیرا پھیری ، دائیں طرف کے سٹرنگ ہیرا پھیری ، مڈ اسٹرنگ ہیرا پھیری کے لئے وی بی اے پروگرامنگ زبان میں سٹرنگ ہیرا پھیری ایک اہم حصہ ہے۔



10. Date & Time:

In Visual Basic for Application, we used a date and time macro in excel VBA to get the year of a date, to declare the date, to Initialize date.

وژوئل بیسک فار ایپلی کیشن میں ، ہم نے ایکسل وی بی اے میں تاریخ اور وقت میکرو کا استعمال کرتے ہوئے تاریخ کا سال حاصل کرنے ، تاریخ کا اعلان کرنے ، تاریخ کو شروع کرنے کے ل.۔




11. Events:

In Visual Basic for Application, an event which is also known as workbook events is defined as an action that is used to execute a specific macro in Excel VBA. With this Event in workbook, VBA Program automatically executes an event after a user specifies the code for an event that has already occurred.

وژوئل بیسک فار ایپلی کیشن میں ، ایک ایونٹ جس کو ورک بوک ایونٹس بھی کہا جاتا ہے ایک ایسی کارروائی کے طور پر بیان کیا گیا ہے جو ایکسل وی بی اے میں ایک مخصوص میکرو کو انجام دینے کے لئے استعمال ہوتا ہے۔ ورک بک میں اس ایونٹ کے ساتھ ، وی بی اے پروگرام خود بخود واقعہ پر عمل درآمد کرتا ہے جب کسی صارف نے کسی واقعہ کے لئے کوڈ کی وضاحت کی ہے جو پہلے ہی واقع ہوچکا ہے۔



12.Array:

In Excel Visual Basic for Application, an array is defined as a single variable with many compartments to store the values, as compared to a single/typical variable that store only one value in  a single storage compartment. Each element contains one value in an array.

ایکسل ایکوئل بیسک فار ایپلی کیشن میں ، ایک صف کو ایک واحد متغیر کے طور پر بیان کیا جاتا ہے جس میں اقدار کو ذخیرہ کرنے کے لئے بہت سارے کمپارٹمنٹس ہوتے ہیں ، اس کے مقابلے میں ایک واحد / عام متغیر جو ایک ہی اسٹوریج ٹوکری میں صرف ایک ہی قیمت رکھتا ہے۔ ہر عنصر میں ایک صف میں ایک قدر ہوتی ہے۔




13. Function and Sub:

Function and Sub is the most important components and tools in Excel Visual Basic for Application (VBA). The main difference between the Function and Sub is that “A Function returns a value of tasks performed” and “A Sub performs a task but does not return a value.

ایکسل بصری بنیادی کے لئے ایپلی کیشن (وی بی اے) میں فنکشن اور سب سب سے اہم اجزاء اور ٹولز ہیں۔ فنکشن اور سب کے درمیان بنیادی فرق یہ ہے کہ "ایک فنکشن انجام دیئے گئے کاموں کی قیمت لوٹاتا ہے" اور "ایک سب ایک کام انجام دیتا ہے لیکن قیمت واپس نہیں کرتا ہے۔




14. Application Object:

In Visual Basic for Application (VBA), entire excel application is represented as Application Object or refers to the host application of excel.

وژوئل بیسک فار ایپلی کیشن (VBA) میں ، ایکسل کی پوری ایپلی کیشن کو بطور ایپلیکیشن آبجیکٹ پیش کیا جاتا ہے یا ایکسل کی میزبان ایپلی کیشن سے مراد ہے۔




15. ActiveX Controls:

In Excel VBA, those controls which are used to automate any application with VBA are most frequently and commonly known as ActiveX Controls. There are different ActiveX Controls In Excel Worksheet or User form and performs various tasks and operations In excel Active Workbook.

ایکسل وی بی اے میں ، وہ کنٹرولز جو وی بی اے کے ساتھ کسی بھی درخواست کو خودکار کرنے کے لئے استعمال ہوتے ہیں وہ اکثر اور عام طور پر ایکٹو ایکس کنٹرولز کے نام سے مشہور ہیں۔ ایکسل ورکشیٹ یا صارف کے فارم میں مختلف ایکٹو ایکس کنٹرول ہیں اور ایکسل ایکٹو ورک بک میں مختلف کام اور کام انجام دیتے ہیں۔



16. User forms:

In Excel VBA, a user form is a custom-built dialog box that facilitates the user of program to enter data in more controllable and easier way.  

 ایکسل وی بی اے میں ، صارف فارم ایک ایسا کسٹم بلٹ ڈائیلاگ باکس ہے جو پروگرام کے صارف کو زیادہ سے زیادہ قابل کنٹرول اور آسان طریقے سے ڈیٹا داخل کرنے میں سہولت فراہم کرتا ہے۔


 

  

 

 


Comments

Popular posts from this blog

Chapter 2 - Creating Macros - Visual Basic For Applications