1
0
Fork 0
libreoffice/helpcontent2/source/text/sbasic/shared/03103600.xhp
Daniel Baumann 8e63e14cf6
Adding upstream version 4:25.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-22 16:20:04 +02:00

205 lines
No EOL
15 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<meta>
<topic id="textsbasicshared03103600xml" indexer="include" status="PUBLISH">
<title id="tit" xml-lang="en-US">TypeName Function; VarType Function</title>
<filename>/text/sbasic/shared/03103600.xhp</filename>
</topic>
</meta>
<body>
<section id="typename">
<bookmark xml-lang="en-US" branch="index" id="bm_id3143267">
<bookmark_value>TypeName function</bookmark_value>
<bookmark_value>VarType function</bookmark_value>
<bookmark_value>Basic Variable Type constants</bookmark_value>
</bookmark>
<h1 id="hd_id3143267"><link href="text/sbasic/shared/03103600.xhp">TypeName Function; VarType Function</link></h1>
<paragraph id="par_id3159157" role="paragraph" xml-lang="en-US">Returns text or a numeric value that contain type information for a variable.</paragraph>
</section>
<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
<bascode>
<paragraph id="par_id3155341" role="bascode" xml-lang="en-US" localize="false">TypeName (Varname As Variant) As String</paragraph>
<paragraph id="par_id3155342" role="bascode" xml-lang="en-US" localize="false">VarType (Varname As Variant) As Integer</paragraph>
</bascode>
<embed href="text/sbasic/shared/00000003.xhp#functvalue"/>
<list type="unordered">
<listitem>
<paragraph id="par_id591667555032629" role="listitem">A text for <literal>TypeName</literal> suffixed with '()' for arrays.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id371667555034757" role="listitem">An integer for <literal>VarType</literal>. The number 8192 is added to the returned value for arrays of type <literal>VarType</literal>.</paragraph>
</listitem>
</list>
<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
<paragraph id="par_id3148664" role="paragraph" xml-lang="en-US"> <emph>Varname</emph>: The variable name that you want to determine the type of.</paragraph>
<paragraph role="paragraph" id="par_id461667489910930">The following values are returned:</paragraph>
<section id="VarType_constants">
<table id="tbl_id3153362">
<tablerow>
<tablecell>
<paragraph id="par_id3145171" role="tablehead" xml-lang="en-US">TypeName<br/>values</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id051620170608269696" role="tablehead" xml-lang="en-US">Named<br/>constant</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3156212" role="tablehead" xml-lang="en-US" localize="false">VarType<br/>values</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154684" role="tablehead" xml-lang="en-US">Variable type</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell colspan="2"><paragraph id="par_id401667566896518" role="paragraph" localize="false">…()</paragraph></tablecell>
<tablecell><paragraph id="par_id561667566907413" role="paragraph" localize="false">8192</paragraph></tablecell>
<tablecell><paragraph id="par_id501667566908366" role="paragraph" xml-lang="en-US"><literal>Array</literal> of variables</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell colspan="2"><paragraph id="par_id3151041" role="paragraph" localize="false">Boolean</paragraph></tablecell>
<tablecell><paragraph id="par_id3153367" role="paragraph" localize="false">11</paragraph></tablecell>
<tablecell><paragraph id="par_id3148645" role="paragraph" xml-lang="en-US"><literal>Boolean</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell colspan="2"><paragraph id="par_id3151042" role="paragraph" localize="false">Byte</paragraph></tablecell>
<tablecell><paragraph id="par_id3253367" role="paragraph" localize="false">17</paragraph></tablecell>
<tablecell><paragraph id="par_id3158645" role="paragraph" xml-lang="en-US"><literal>Byte</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3153138" role="paragraph" localize="false">Date</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608329367" role="paragraph" localize="false">V_DATE</paragraph></tablecell>
<tablecell><paragraph id="par_id3153363" role="paragraph" localize="false">7</paragraph></tablecell>
<tablecell><paragraph id="par_id3155411" role="paragraph" xml-lang="en-US"><literal>Date</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id051620170608331783" role="paragraph" localize="false">Currency</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608333476" role="paragraph" localize="false">V_CURRENCY</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608333808" role="paragraph" localize="false">6</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608331416" role="paragraph" xml-lang="en-US"><literal>Currency</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3146975" role="paragraph" localize="false">Double</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608337319" role="paragraph" localize="false">V_DOUBLE</paragraph></tablecell>
<tablecell><paragraph id="par_id3150486" role="paragraph" localize="false">5</paragraph></tablecell>
<tablecell><paragraph id="par_id3148616" role="paragraph" xml-lang="en-US">Double-precision floating-point variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell colspan="2"><paragraph id="par_id401657666896518" role="paragraph" localize="false">Error</paragraph></tablecell>
<tablecell><paragraph id="par_id566617566907413" role="paragraph" localize="false">11</paragraph></tablecell>
<tablecell><paragraph id="par_id501666576908366" role="paragraph" xml-lang="en-US">Error type variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3148457" role="paragraph" localize="false">Integer</paragraph></tablecell>
<tablecell><paragraph id="par_id05162017060833922" role="paragraph" localize="false">V_INTEGER</paragraph></tablecell>
<tablecell><paragraph id="par_id3145647" role="paragraph" localize="false">2</paragraph></tablecell>
<tablecell><paragraph id="par_id3154490" role="paragraph" xml-lang="en-US"><literal>Integer</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3149960" role="paragraph" localize="false">Long</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608332124" role="paragraph" localize="false">V_LONG</paragraph></tablecell>
<tablecell><paragraph id="par_id3154513" role="paragraph" localize="false">3</paragraph></tablecell>
<tablecell><paragraph id="par_id3151318" role="paragraph" xml-lang="en-US"><literal>Long</literal> integer variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell colspan="2"><paragraph id="par_id3146972" role="paragraph" localize="false">Object</paragraph></tablecell>
<tablecell><paragraph id="par_id3154482" role="paragraph" localize="false">9</paragraph></tablecell>
<tablecell><paragraph id="par_id3150323" role="paragraph" xml-lang="en-US"><literal>Object</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3148405" role="paragraph" localize="false">Single</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608337392" role="paragraph" localize="false">V_SINGLE</paragraph></tablecell>
<tablecell><paragraph id="par_id3149020" role="paragraph" localize="false">4</paragraph></tablecell>
<tablecell><paragraph id="par_id3147341" role="paragraph" xml-lang="en-US">Single-precision floating-point variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3155901" role="paragraph" localize="false">String</paragraph></tablecell>
<tablecell><paragraph id="par_id05162017060833587" role="paragraph" localize="false">V_STRING</paragraph></tablecell>
<tablecell><paragraph id="par_id3155960" role="paragraph" localize="false">8</paragraph></tablecell>
<tablecell><paragraph id="par_id3146313" role="paragraph" xml-lang="en-US"><literal>String</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell colspan="2"><paragraph id="par_id3145149" role="paragraph" localize="false">Variant</paragraph></tablecell>
<tablecell><paragraph id="par_id3154021" role="paragraph" localize="false">12</paragraph></tablecell>
<tablecell><paragraph id="par_id3145789" role="paragraph" xml-lang="en-US"><literal>Variant</literal> variable (can contain all types specified by the definition)</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3148630" role="paragraph" localize="false">Empty</paragraph></tablecell>
<tablecell><paragraph id="par_id051620170608331395" role="paragraph" localize="false">V_EMPTY</paragraph></tablecell>
<tablecell><paragraph id="par_id3152584" role="paragraph" localize="false">0</paragraph></tablecell>
<tablecell><paragraph id="par_id3151278" role="paragraph" xml-lang="en-US">Uninitialized <literal>Variant</literal> variable</paragraph></tablecell>
</tablerow>
<tablerow>
<tablecell><paragraph id="par_id3154576" role="paragraph" localize="false">Null</paragraph></tablecell>
<tablecell><paragraph id="par_id05162017060833692" role="paragraph" localize="false">V_NULL</paragraph></tablecell>
<tablecell><paragraph id="par_id3166424" role="paragraph" localize="false">1</paragraph></tablecell>
<tablecell><paragraph id="par_id3145131" role="paragraph" xml-lang="en-US">No valid data</paragraph></tablecell>
</tablerow>
</table>
</section>
<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
<embed href="text/sbasic/shared/00000003.xhp#err5"/>
<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
<paragraph id="par_idm1340870070" role="bascode" localize="false">Sub TypeName_VarType_example</paragraph>
<paragraph id="par_idm1340868768" role="bascode" localize="false"> Const __Object=9, __Error=10, __Boolean=11, __Variant=12, __Byte=17, _</paragraph>
<paragraph id="par_idm1340863840" role="bascode" localize="false"> __Array = 8192, aText = "Lorem ipsum dolor sit amet, consectetur …"</paragraph>
<paragraph id="par_idm1340862608" role="bascode" localize="false"> Dim int16 As Integer, int32() As Long ' V_INTEGER, V_LONG</paragraph>
<paragraph id="par_id051620170608333887" role="bascode" localize="false"> Dim flt32!, flt64() As Double ' V_SINGLE, V_DOUBLE</paragraph>
<paragraph id="par_id051620170608333925" role="bascode" localize="false"> Dim curr@, dat3 As Date ' V_CURRENCY, V_DATE</paragraph>
<paragraph role="bascode" id="bas_id871667494989338" localize="false"> Dim strng() As String, objct() As Object ' V_STRING, …</paragraph>
<paragraph role="bascode" id="bas_id971667494996761" localize="false"> Dim bool As Boolean, unkwn(), byt3 As Byte ' …, V_EMPTY, …</paragraph>
<paragraph role="bascode" id="bas_id971667949496761" localize="false"> Dim table(-3 To 5)</paragraph>
<paragraph id="par_idm1340861376" role="bascode" localize="false"> MsgBox _</paragraph>
<paragraph id="par_idm1340860032" role="bascode" localize="false"> TypeName(int16) &amp;" "&amp; Vartype(int16) &amp;" "&amp; V_INTEGER &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph role="bascode" id="bas_id841667495736985" localize="false"> TypeName(int32) &amp;" "&amp; Vartype(int32) &amp;" "&amp; V_LONG+__Array &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph role="bascode" id="bas_id621667495663321" localize="false"> TypeName(flt32) &amp;" "&amp; VarType(flt32) &amp;" "&amp; V_SINGLE &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph role="bascode" id="bas_id661667495665110" localize="false"> TypeName(flt64) &amp;" "&amp; VarType(flt64) &amp;" "&amp; V_DOUBLE+__Array &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph id="par_idm1340858736" role="bascode" localize="false"> TypeName(dat3) &amp;" "&amp; VarType(dat3) &amp;" "&amp; V_DATE &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph id="par_idm1340857424" role="bascode" localize="false"> TypeName(curr) &amp;" "&amp; VarType(curr) &amp;" "&amp; V_CURRENCY &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph id="par_idm1340856128" role="bascode" localize="false"> TypeName(atext) &amp;" "&amp; VarType(aText) &amp;" "&amp; V_STRING &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph id="par_id051620170608339345" role="bascode" localize="false"> TypeName(strng) &amp;" "&amp; VarType(strng) &amp;" "&amp; V_STRING+__Array &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph id="par_id051620170608347372" role="bascode" localize="false"> TypeName(objct) &amp;" "&amp; VarType(objct) &amp;" "&amp; __Object+__Array &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph id="par_id051620160708347372" role="bascode" localize="false"> TypeName(unkwn) &amp;" "&amp; VarType(unkwn) &amp;" "&amp; V_EMPTY &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph role="bascode" id="bas_id41667495466465" localize="false"> TypeName(bool) &amp;" "&amp; VarType(bool) &amp;" "&amp; __Boolean &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph role="bascode" id="bas_id781667495510795" localize="false"> TypeName(varnt) &amp;" "&amp; VarType(varnt) &amp;" "&amp; V_EMPTY &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph role="bascode" id="bas_id161867491557562" localize="false"> TypeName(table) &amp;" "&amp; VarType(table) &amp;" "&amp;__Variant+__Array &amp;" "&amp; Chr(13) &amp;_</paragraph>
<paragraph role="bascode" id="bas_id181667495517562" localize="false"> TypeName(byt3) &amp;" "&amp; VarType(byt3) &amp;" "&amp; __Byte _</paragraph>
<paragraph id="par_id3148817" role="bascode" xml-lang="en-US"> ,, "Data types in $[officename] Basic"</paragraph>
<paragraph role="bascode" id="bas_id321667571151683" localize="false"> Msgbox "TypeName(table): "&amp;TypeName(table) &amp;Chr(13)&amp; _</paragraph>
<paragraph role="bascode" id="bas_id731667571152620" localize="false"> "VarType(table)="&amp;Vartype(table) _</paragraph>
<paragraph role="bascode" id="bas_id191667571153141" xml-lang="en-US"> ,,"Array of Variant values"</paragraph>
<paragraph id="par_idm1340952896" role="bascode" localize="false">End Sub ' TypeName_VarType_example</paragraph>
</bascode>
<section id="relatedtopics">
<embed href="text/sbasic/shared/03100700.xhp#const_h1"/>
<embed href="text/sbasic/shared/03102100.xhp#Dimh1"/>
<embed href="text/sbasic/shared/03010102.xhp#msgbox_h1"/>
</section>
</body>
</helpdocument>