ReDim Statement

විචල්‍ය ආරාවකට ප්‍රකාශ කරයි.

කාරක රීතිය:


[ReDim]Dim VarName [(start To end)] [As VarType][, VarName2 [(start To end)] [As VarType][,...]]

ඔබට, විකල්පයක් වශයෙන්, විශාලත්වය නැවත සකස් කර ගන්නා පෙළෙහි අඩංගු දේ එසේම පවත්වා ගැනීමට වුවමනා නම් Preserve මූල පදය පරාමිතියක් ලෙස ඇතුලත් කළ හැක.

පරාමිතීන්:

VarName: ඕනෑම විචල්‍යයක් හෝ ආරාවක්

Start, End: මූලිකාංග ගණන අර්ථ දක්වන සංඛ්‍යාත්මක අගයන් හෝ නියතයන් (NumberElements=(end-start)+1) සහ සුචි පෙළ.

ReDim භාවිතා කරනු ලබන්නේ පටිපාටියක් තුල නම් Start සහ End සංඛ්‍යාත්මක ප්‍රකාශන විය හැක.

VarType: විචල්‍ය වර්ගය ප්‍රකාශ කරන මූල පදය.

Keyword: විචල්‍ය වර්ගය

Bool: බූලියන් ආකාරයේ චිචල්‍ය (සත්‍යය. අසත්‍යය)‍

Date: දිනය ආකාරයේ විචල්‍ය

Double: දශමස්ථානයක් සහිත සංඛ්‍යා ආකාරයේ විචල්‍ය (1.79769313486232x10E308 - 4.94065645841247x10E-324)

Integer: පූර්ණාංක ආකාරයේ විචල්‍ය (-32768 - 32767)

Long: දිගු පූර්ණාංක ආකාරයේ විචල්‍ය (-2,147,483,648 - 2,147,483,647)

Object: වස්තු ආකාරයේ විචල්‍ය (Set! වලට පසුව පමණක් ප්‍රකාශයට පත්කල හැකිය)

[Single]: තනි නොබැඳි-ලක්ෂ්‍ය විචල්‍යය (3.402823x10E38 - 1.401298x10E-45). කිසිම මූල පදයක් සඳහන් කර නොමති නම් විචල්‍යයක් 'තනි' ලෙස අර්ථ දක්වනු ලබේ. එසේ නොමති නම් DefBool සිට DefVar දක්වා වූ ප්‍රකාශයක් යොදා ගනු ලබේ.

String: අක්ෂර පෙළ ආකාරයේ උපරිමව ASCII අක්ෂර 64,000 ක් රදවාගත හැකි විචල්‍ය.

Variant: විචල ආකාරයේ විචල්‍ය (සියලුම ආකාරයේ විචල්‍ය රදවා ගත හැකිය. ප්‍රකාශනයේදි විචලය ආකාරය සකස් කරනු ලැබේ.)

In LibreOffice Basic, you do not need to declare variables explicitly. However, you need to declare an array before you can use them. You can declare a variable with the Dim statement, using commas to separate multiple declarations. To declare a variable type, enter a type-declaration character following the name or use a corresponding key word.

LibreOffice Basic supports single or multi-dimensional arrays that are defined by a specified variable type. Arrays are suitable if the program contains lists or tables that you want to edit. The advantage of arrays is that it is possible to address individual elements according to indexes, which can be formulated as numeric expressions or variables.

There are two ways to set the range of indices for arrays declared with the Dim statement:

DIM text(20) As String REM 21 elements numbered from 0 to 20

DIM text(5 to 25) As String REM 21 elements numbered from 5 to 25

DIM text$(-15 to 5) As String REM 21 elements (0 inclusive),

rem numbered from -15 to 5

Variable fields, regardless of type, can be made dynamic if they are dimensioned by ReDim at the procedure level in subroutines or functions. Normally, you can only set the range of an array once and you cannot modify it. Within a procedure, you can declare an array using the ReDim statement with numeric expressions to define the range of the field sizes.

උදාහරණය:


Sub ExampleRedim
Dim iVar() As Integer, iCount As Integer
ReDim iVar(5) As Integer
For iCount = 1 To 5
    iVar(iCount) = iCount
Next iCount
ReDim iVar(10) As Integer
For iCount = 1 To 10
    iVar(iCount) = iCount
Next iCount
End Sub

Please support us!