འགྱུར་ཚད་བེད་སྤྱོད་

གཤམ་ལ་LibreOffice ཧུང་ནང་འགྱུར་ཚད་ཀྱི་གཞི་རྩའི་སྤྱོད་ཐབས་ངོ་སྤྲོད་བྱེད།

འགྱུར་ཚད་ཤན་འབྱེད་རྟགས་ཀྱིས་མིང་འདོགས་

འགྱུར་ཚད་མིང་མང་ཤོས་ལ་ 255 ཡིག་རྟགས་ཚུད་ཆོག འགྱུར་ཚད་མིང་གི་ཡིག་རྟགས་ཨང་དང་པོ་ངེས་པར་དུ་ནི་ཡིག་འབྲུ་ 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'
warning

འགྱུར་གྲངས་ཞིག་གིས་གསལ་བསྒྲགས་ནི་རིགས་ཞིག་ཡིན་མིང་གཅིག་པའི་འགྱུར་ཚད་གང་ལ་བསྒྲགས་ནི་མི་འདྲ་བའི་རིགས་མ་ཡིན།


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
note

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

Option Explicit བརྗེད་པ་ངེས་པར་དུ་སྨོ་ལིང་ནང་གི་ཕྲེང་དང་པོ་ཡིན་ཨང་དང་པོའི་ཡན་ལག་བྱ་རིམ་གོང་ལ་གནས་ཡོད།རྒྱུན་དུ་གྲངས་ཚོ་ཁོ་ན་ལ་མངོན་ཚུལ་གསལ་བསྒྲགས་དགོས་ངེས་ཡིན། གཞན་གྱི་འགྱུར་ཚད་ཡོད་ཚད་རིགས་བཞིན་གསལ་བསྒྲགས་ཡིག་རྟགས་གསལ་བསྒྲགས་བྱེད་གལ་སྲིད་རིགས་གསལ་བསྒྲགས་ཡིག་རྟགས་བསྡུས་ན་གསལ་བསྒྲགས་ནི་་རིགས་རྐྱང་པའིདག་ཚད་ཁས་ལེན་བྱེད།

འགྱུར་ཚད་རིགས་

LibreOffice ཧུང་གིས་འགྱུར་ཚད་ཁག་བཞི་ལ་རྒྱབ་སྐྱོར་བྱེད་

ཧྲིལ་གྲངས་འགྱུར་ཚད

ཧྲིལ་གྲངས་འགྱུར་ཚད་ཀྱིས་ཁྱབ་ཁོངས་ -32768 ནས་ 32767ཡིན་ གལ་སྲིད་ཧྲིལ་གྲངས་འགྱུར་ཚད་འཕྱོ་ཚིག་གྲངས་ཐང་གཏན་འཁེལ་བྱེད་ སིལ་གྲངས་ཆ་ཤས་ནི་གཤམ་གྱིས་ཧྲིལ་གྲངས་གཅིག་ལ་བརྗེ་བསྒྱུར་བྱེད་ ཧྲིལ་གྲངས་འགྱུར་ཚད་རྒྱུད་རིམ་ནང་གིས་རྩེས་རྒྱག་མྱུར་ཚད་ནི་ཧ་ཅང་མགྱོགས་བསྐྱར་འཁོར་ནང་གིས་རྩིས་རྒྱག་ཆས་འགྱུར་ཚད་སྤྱོད་རྒྱུད་འཚམས་པ།


Dim Variable%
Dim Variable As Integer

ཧྲིལ་གྲངས་རིང་པོ་འགྱུར་ཚད་

ཧྲིལ་གྲངས་ཐང་རིང་པོ་འགྱུར་ཚད་ཀྱི་ཁྱབ་ཁོངས་ནི་ -2147483648 ནས་ 2147483647ཡིན།གལ་སྲིད་ཧྲིལ་གྲངས་ཐང་རིང་པོ་འགྱུར་ཚད་དེ་་འཕྱོ་ཚིག་གྲངས་ཐང་ལ་གཏན་འཁེལ་བྱེད་ན་སིལ་གྲངས་ཆ་ཤས་དེ་གཤམ་གྱིས་ཧྲིལ་གྲངས་གཅིག་ལ་བརྗེ་བསྒྱུར་བྱེད་ ཧྲིལ་གྲངས་ཐང་རིང་པོ་འགྱུར་ཚད་ནི་ཡིག་་ཚགས་བཞི་ཡི་ནང་ཉར་དགོས་ངེས།དེ་རིགས་ཀྱི་གསལ་བསྒྲགས་ཡིན་རྟགས་ནི་"&"


Dim Variable&
Dim Variable As Long

Decimal Variables

Decimal variables can take positive or negative numbers or zero. Accuracy is up to 29 digits.

You can use plus (+) or minus (-) signs as prefixes for decimal numbers (with or without spaces).

If a decimal number is assigned to an integer variable, LibreOffice Basic rounds the figure up or down.

དག་ཚད་རྐྱང་པའི་འགྱུར་ཚད་

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

དངུལ་ལོར་འགྱུར་ཚད་

དངུལ་ལོར་འགྱུར་ཚད་ནང་ཁུལ་གསོག་ཉར་ནི་ གནས་64གྲངས་ཡིན་ (ཡིག་ཚགས་8 )རྒྱས་བཅད་གནས་གྲངས་ཀྱི་སིལ་གྲངས་མངོན་པ་གཞན་ཡང་གནས་ 15 སིལ་གྲངས་མ་ཡིན་པ་དང་གནས་ 4 སིལ་གྲངས་ཚུད་ཡོད་ཐང་ལེན་པའི་ཁྱབ་ཁོངས་ནི་ -922337203685477.5808 ནས་ +922337203685477.5807དབར་ཡིན། དངུལ་ལོར་འགྱུར་ཚད་ནི་རྩེས་རྒྱག་དངུལ་ལོའི་ཐང་བེད་སྤྱོད་དང་ཆེས་དག་ཚད་ལྡན་ཡོད་རིགས་གསལ་བསྒྲགས་རྟགས་ནི་ "@"


Dim Variable@
Dim Variable As Currency

Literals for integers

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 "$".

tip

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

Literals for Dates

Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:


  start_date = #12/30/1899# ' = 1
  dob = #2010-09-28#

The Variant type

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
note

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.

warning

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

འགྱུར་ཚད་ཐོག་མའི་ཐང་

གསལ་བསྒྲགས་གཅིག་འགྱུར་ཚད་བྱས་ན་རང་འགུལ་གྱིས་སྟོང་པའི་ཐང་བཀད་སྒྲིག་བྱེད་གཤམ་གྱིས་ཚད་ལྡན་ལ་དོ་སྣང་བྱེད་

གསལ་བསྒྲགས་གྲངས་ཀ་འགྱུར་ཚད་རྗེས་རང་འགུལ་གྱིས་ཐང་"0"གཏན་འཁེལ་བྱེད།

ཚེས་གྲངས་འགྱུར་ཚད་ནི་ནང་འཁུལ་ལ་ཐང་ 0གཏན་འཁེལ་བྱེད་ DayMonthYear ཡང་ན་ HourMinuteSecond བེད་སྤྱོད་བྱེད་མཚུངས་ རྟེན་གྲངས་ནི་དེ་ཐང་"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

Please support us!