LibreOffice 25.2 Help
LibreOffice বেসিকে ভেরিয়েবলগুলোর প্রাথমিক ব্যবহার নিচে বর্ণনা করা হয়েছে।
একটি ভেরিয়েবল নাম সর্বোচ্চ ২৫৫ অক্ষরের সমন্বয়ে গঠিত। একটি ভেরিয়েবল নামের প্রথম অক্ষরঅবশ্যই A-Z অথবা a-z অক্ষরের হতে হবে। একটি ভেরিয়েবল নামে সংখ্যা ব্যবহার করা যাবে, কিন্তু বিরাম চিহ্ন এবং বিশেষ অক্ষরের ব্যবহার অনুমোদিত নয়, শুধুমাত্র নিম্নরেখা অক্ষর (" _ ") ব্যতীত। LibreOffice বেসিক ভেরিয়েবল আইডেন্টিফায়ার অক্ষরের আকারের সংবেদনশীল নয়। ভেরিয়েবল নামে ফাঁকা স্থান থাকতে পারে কিন্তু যদি থাকে তাহলে তা বর্গাকার বন্ধনী দ্বারা আবদ্ধ থাকে।
ভেরিয়েবল আইডেন্টিফায়ারের উদাহরণ:
MyNumber=5 'Correct'
MyNumber5=15 'Correct'
MyNumber_5=20 'Correct'
My Number=20 'Not valid, variable with space must be enclosed in square brackets'
[My Number]=12 'Correct'
DéjàVu=25 'Not valid, special characters are not allowed'
5MyNumber=12 'Not valid, variable may not begin with a number'
Number,Mine=12 'Not valid, punctuation marks are not allowed'
LibreOffice বেসিকে ভেরিয়েবল স্পষ্টভাবে ডিক্লেয়ার করার প্রয়োজন নেই। একটি ভেরিয়েবল Dim স্টেটমেন্টের সাহায্যে ডিক্লেয়ার করা যাবে। আপনি একটি কমার সাহায্যে নামগুলো পৃথক করার মাধ্যমে একই সাথে একাধিক ভেরিয়েবল ডিক্লেয়ার করতে পারেন। ভেরিয়েবলের টাইপ উল্লেখ করার জন্য, নামের পরে হয় একটি টাইপ ডিক্লেয়ারেশন চিহ্ন অথবা উপযুক্ত কীওয়ার্ড ব্যবহার করুন।
ভেরিয়েবল ডিক্লেয়ার করার উদাহরণ:
Dim a$ 'Declares the variable "a" as a String'
Dim a As String 'Declares the variable "a" as a String'
Dim a$, b As Integer 'Declares one variable as a String and one as an Integer'
Dim c As Boolean 'Declares c as a Boolean variable that can be TRUE or FALSE'
আপনি একবার একটি ধরন হিসেবে ভেরিয়েবল ডিক্লেয়ার করলে, ভিন্ন ধরনের ভেরিয়েবল একই নামে পুনরায় ডিক্লেয়ার করতে পারেন না!
When you declare multiple variables in a single line of code you need to specify the type of each variable. If the type of a variable is not explicitly specified, then Basic will assume that the variable is of the Variant type.
' Both variables "a" and "b" are of the Integer type
Dim a As Integer, b As Integer
' Variable "c" is a Variant and "d" is an Integer
Dim c, d As Integer
' A variable can also be explicitly declared as a Variant
Dim e As Variant, f As Double
The Variant type is a special data type that can store any kind of value. To learn more, refer to the section The Variant type below.
ভেরিয়েবল ডিক্লেয়ার বাধ্য করতে নিচের কমান্ডটি দিন:
Option Explicit
প্রথম SUB এর পূর্বে, সুনির্দিষ্ট অপশন বিবরণ মডিউলের প্রথম লাইনে থাকতে হবে। সাধারণভাবে, শুধুমাত্র অ্যারে সুনির্দিষ্টভাবে ডিক্লেয়ার করা প্রয়োজন। অন্য সব ভেরিয়বল টাইপ ডিক্লেয়ারেশন অক্ষর অনুসারে, অথবা পূর্বনির্ধারিত টাইপ একক হিসেবে -যদি বাতিল করা হয় - তাহলে সেই অনুসারে ডিক্লেয়ার করা হবে।
LibreOffice বেসিক চারটি ভেরিয়েবল ক্লাস সমর্থন করে:
সংখ্যাসূচক ভেরিয়েবল সংখ্যা মান ধারণ করতে পারে। কিছু ভেরিয়েবল বড় অথবা ক্ষুদ্র সংখ্যা সংরক্ষণ করতে এবং অন্যান্য ভেরিয়েবল ফ্লোটিং পয়ন্ট অথবা ভগ্নাংশ সংখ্যার জন্য ব্যবহার করা হয়।
স্ট্রিং ভেরিয়েবলে অক্ষর স্ট্রিং রয়েছে।
বুলিয়ান ভেরিয়েবলে হয় TRUE অথবা FALSE মান থাকে।
বস্তু ভেরিয়েবল বিভিন্ন ধরনের বস্তু সংরক্ষণ করতে পারে, যেমন একটি নথির সারণি এবং নথি।
পূর্ণসংখ্যা ভেরিয়েবলের পরিসর ৩২৭৬৮ থেকে ৩২৭৬৭ পর্যন্ত। যদি আপনি একটি পূর্ণসংখ্যা ভেরিয়েবলে একটি ফ্লোটিং পয়েন্ট মান প্রদান করেন, দশমিক স্থান পরবর্তী পূর্ণসংখ্যাতে পরিণত হবে। পূর্ণসংখ্যা ভেরিয়েবল প্রসিজারে দ্রুত গণনা করা হয় এবং লুপে কাউন্টার ভেরিয়েবলের জন্য উপযুক্ত। একটি পূর্ণসংখ্যা ভেরিয়েবলের জন্য মেমরির দুই বাইট জায়গা প্রয়োজন। " % " হলো টাইপ ডিক্লেয়ারেশন অক্ষর।
Dim Variable%
Dim Variable As Integer
দীর্ঘ পূর্ণসংখ্যা ভেরিয়েবলের পরিসীমা -২১৪৭৪৮৩৬৪৭ থেকে ২১৪৭৪৮৩৬৪৭পর্যন্ত। যদি আপনি একটি দীর্ঘ পূর্ণসংখ্যা ভেরিয়েবলে একটি ফ্লোটিং পয়েন্ট মান বরাদ্দ করেন, তাহলে দশমিক স্থান পরবর্তী পূর্ণসংখ্যায় রূপান্তরিত হবে। প্রসিজারে দীর্ঘ পূর্ণসংখ্যা ভেরিয়েবল দ্রুত গণনা করা হয় এবং বড় মানের জন্য লুপে কাউন্টার ভেরিয়েবলের জন্য উপযুক্ত। একটি দীর্ঘ পূর্ণসংখ্যা ভেরিয়েবলের জন্য মেমরির চার বাইট স্থান প্রয়োজন। " & " হলো টাইপ ডিক্লেয়ারেশন অক্ষর।
Dim Variable&
Dim Variable As Long
দশমিক ভেরিয়েবল হিসেবে ধ্বনাত্মক অথবা ঋনাত্মক সংখ্যা অথবা শূন্য ব্যবহৃত হয়। ২৯ ডিজিট পর্যন্ত নির্ভুলতা থাকতে হবে।
আপনি দশমিক সংখ্যার প্রিফিক্স হিসেবে যোগ (+) অথবা বিয়োগ (-) চিহ্ন ব্যবহার করতে পারেন (ফাঁকা স্থান সহ বা ব্যতীত)।
যদি একটি দশমিক সংখ্যাকে ইনটিজার ভেরিয়েবল হিসেবে নিযুক্ত করা হয় তাহলে LibreOffice বেসিক সংখ্যাটিকে উপরের বা নিচের পূর্ণসংখ্যায় পরিণত করে।
Single variables can take positive or negative values ranging from 3.402823 x 10E38 to 1.401298 x 10E-45. Single variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Single variables are suitable for mathematical calculations of average precision. Calculations require more time than for Integer variables, but are faster than calculations with Double variables. A Single variable requires 4 bytes of memory. The type-declaration character is "!".
Dim Variable!
Dim Variable As Single
Double variables can take positive or negative values ranging from 1.79769313486232 x 10E308 to 4.94065645841247 x 10E-324. Double variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Double variables are suitable for precise calculations. Calculations require more time than for Single variables. A Double variable requires 8 bytes of memory. The type-declaration character is "#".
Dim Variable#
Dim Variable As Double
মূদ্রা ভেরিয়েবল ৬৪-বিট (৮ বাইট) সংখ্যা হিসেবে অভ্যন্তরীণভাবে সংরক্ষিত থাকে এবং ১৫ দশমিক নয় এমন এবং ৪ দশমিক স্থানের সঙ্গে একটি নির্দিষ্ট দশমিক সংখ্যা হিসেবে প্রদর্শিত হয়। মানের পরিসর -922337203685477 5808 থেকে +922337203685477 5807। শুদ্ধতম মূদ্রা গণনার জন্য একটি মূদ্রা ভেরিয়েবল ব্যবহার করা হয়। টাইপ ডিক্লেয়ারেশন অক্ষরটি হলো " @ "।
Dim Variable@
Dim Variable As Currency
Numbers can be encoded using octal and hexadecimal forms.
xi = &o13 ' 8 + 3
ci = &h65 ' 6*16 + 5
MAX_Integer = &o77777 ' 32767 = &h7FFF
MIN_Integer = &o100000 ' -32768 = &h8000
MAX_Long = &h7fffffff ' 2147483647 = &o17777777777
MIN_Long = &h80000000 ' -2147483648 = &o20000000000
String variables can hold character strings with up to 2,147,483,648 characters. Each character is stored as the corresponding Unicode value. String variables are suitable for word processing within programs and for temporary storage of any non-printable character up to a maximum length of 2 Gbytes. The memory required for storing string variables depends on the number of characters in the variable. The type-declaration character is "$".
In BASIC String functions, the first character of the string has index 1.
Dim Variable$
Dim Variable As String
বুলিয়ান ভেরিয়েবল দুইটি মানের শুধুমাত্র একটি মান সংরক্ষণ করে: TRUE অথবা FALSE। 0 সংখ্যাটির অর্থ হলো FALSE, অন্যান্য সব মানের অর্থ হলো TRUE।
Dim Variable As Boolean
তারিখ ভেরিয়েবলে শুধুমাত্র অভ্যন্তরীণ বিন্যাসে সংরক্ষিত তারিখ এবং সময়ের মান বিদ্যমান। তারিখ ভেরিয়েবলে Dateserial, Datevalue, Timeserial অথবা Timevalue দ্বারা প্রয়োগকৃত মান স্বয়ংক্রিয়ভাবে অভ্যন্তরীণ বিন্যাসে রূপান্তরিত হয়। তারিখ ভেরিয়েবল Day, Month, Year অথবা Hour, Minute, Second ফাংশন ব্যবহার করে স্বাভাবিক সংখ্যায় রূপান্তরিত হয়। দুইটি সংখ্যার পার্থক্য গণনা করার মাধ্যমে তারিখ/সময়ের মধ্যে তুলনা অভ্যন্তরীণ বিন্যাসের সাহায্যে সক্রিয় করা হয়। এই ভেরিয়েবলসমূহ শুধুমাত্র Date কীওয়ার্ডের সাহায্যে ডিক্লেয়ার করা যায়।
Dim Variable As Date
Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:
#yyyy-mm-dd#
#mm/dd/yyyy#
start_date = #1899-12-30# ' = 0
dob = #2010-09-28#
Variables declared as Variant can handle any data type. This means that the actual data type is defined during runtime as a value is assigned to the variable.
There are three main ways to create a Variant variable, as shown below:
Dim varA ' The type is not specified, hence the variable is a Variant
Dim varB as Variant ' The variable is explicitly declared as a Variant
varC = "abc" ' Previously undeclared variables are treated as Variants
The example below uses the TypeName function to show how the type of a Variant variable changes upon assignment.
Dim myVar As Variant
MsgBox TypeName(myVar) ' Empty
myVar = "Hello!"
MsgBox TypeName(myVar) ' String
myVar = 10
MsgBox TypeName(myVar) ' Integer
A Variant variable is initialized with the Empty special data type. You can use the IsEmpty function to test if a variable is an Empty Variant.
You can also use the keyword Any to declare a variable as a Variant. However, Any is deprecated and is available for backward compatibility.
Arguments with type Variant or Any passed in function calls are not checked for their types.
Dim myVar As Any ' Variable "myVar" is a Variant
কোন ভেরিয়েবল ডিক্লেয়ার করার সাথে সাথে স্বয়ংক্রিয়ভাবে "Null" মান নির্ধারিত হয়। নিম্নের নিয়মাবলী নোট করুন:
সংখ্যাসূচক ভেরিয়েবল ডিক্লেয়ার করার সাথে স্বয়ংক্রিয়ভাবে "0" মান হিসেবে ধার্য হয়।
তারিখ ভেরিয়েবল এর মান হিসেবে অভ্যন্তরীণভাবে 0 বরাদ্দ থাকে; যা তারিখ, মাস, বছর or the ঘন্টা, মিনিট, সেকেন্ড ফাংশন ব্যবহার করে মানটিকে "0" তে রূপান্তর করার সমতুল্য।
স্ট্রিং ভেরিয়েবল ডিক্লেয়ার করা হলে ফাঁকা-স্ট্রিং ("") নিযুক্ত হয়।
LibreOffice বেসিক একটি উল্লেখিত ভেরিয়েবল দ্বারা নির্ধারিত এক বা বহুমাত্রিক অ্যারের সাথে পরিচিত। অ্যারে প্রোগ্রামে তালিকা এবং টেবিল সম্পাদনার জন্য উপযুক্ত। একটি অ্যারের স্বতন্ত্র এলিমেন্ট একটি সংখ্যাসূচক ইনডেক্সের মাধ্যমে নির্দেশিত হতে পারে।
অ্যারেঅবশ্যই Dim স্টেটমেন্টের মাধ্যমে ডিক্লেয়ার করা হয়েছে। একটি অ্যারের ইনডেক্সের পরিসর নির্ধারণ করতে কিছু উপায় রয়েছে:
Dim Text$(20) '21 elements numbered from 0 to 20'
Dim Text$(5,4) '30 elements (a matrix of 6 x 5 elements)'
Dim Text$(5 To 25) '21 elements numbered from 5 to 25'
Dim Text$(-15 To 5) '21 elements (including 0), numbered from -15 to 5'
ইনডেক্সের পরিসরটি একই সাথে ধ্বনাত্মক এবং ঋনাত্মক সংখ্যাকে অন্তর্ভুক্ত করে।
ধ্রুবকগুলোর একটি নির্দিষ্ট মান রয়েছে। এগুলো প্রোগ্রামে শুধুমাত্র একবার নির্ধারণ করা হয় এবং পরে পুনঃনির্ধারণ করা যায় না:
Const ConstName=Expression