1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
<?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) &" "& Vartype(int16) &" "& V_INTEGER &" "& Chr(13) &_</paragraph>
<paragraph role="bascode" id="bas_id841667495736985" localize="false"> TypeName(int32) &" "& Vartype(int32) &" "& V_LONG+__Array &" "& Chr(13) &_</paragraph>
<paragraph role="bascode" id="bas_id621667495663321" localize="false"> TypeName(flt32) &" "& VarType(flt32) &" "& V_SINGLE &" "& Chr(13) &_</paragraph>
<paragraph role="bascode" id="bas_id661667495665110" localize="false"> TypeName(flt64) &" "& VarType(flt64) &" "& V_DOUBLE+__Array &" "& Chr(13) &_</paragraph>
<paragraph id="par_idm1340858736" role="bascode" localize="false"> TypeName(dat3) &" "& VarType(dat3) &" "& V_DATE &" "& Chr(13) &_</paragraph>
<paragraph id="par_idm1340857424" role="bascode" localize="false"> TypeName(curr) &" "& VarType(curr) &" "& V_CURRENCY &" "& Chr(13) &_</paragraph>
<paragraph id="par_idm1340856128" role="bascode" localize="false"> TypeName(atext) &" "& VarType(aText) &" "& V_STRING &" "& Chr(13) &_</paragraph>
<paragraph id="par_id051620170608339345" role="bascode" localize="false"> TypeName(strng) &" "& VarType(strng) &" "& V_STRING+__Array &" "& Chr(13) &_</paragraph>
<paragraph id="par_id051620170608347372" role="bascode" localize="false"> TypeName(objct) &" "& VarType(objct) &" "& __Object+__Array &" "& Chr(13) &_</paragraph>
<paragraph id="par_id051620160708347372" role="bascode" localize="false"> TypeName(unkwn) &" "& VarType(unkwn) &" "& V_EMPTY &" "& Chr(13) &_</paragraph>
<paragraph role="bascode" id="bas_id41667495466465" localize="false"> TypeName(bool) &" "& VarType(bool) &" "& __Boolean &" "& Chr(13) &_</paragraph>
<paragraph role="bascode" id="bas_id781667495510795" localize="false"> TypeName(varnt) &" "& VarType(varnt) &" "& V_EMPTY &" "& Chr(13) &_</paragraph>
<paragraph role="bascode" id="bas_id161867491557562" localize="false"> TypeName(table) &" "& VarType(table) &" "&__Variant+__Array &" "& Chr(13) &_</paragraph>
<paragraph role="bascode" id="bas_id181667495517562" localize="false"> TypeName(byt3) &" "& VarType(byt3) &" "& __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): "&TypeName(table) &Chr(13)& _</paragraph>
<paragraph role="bascode" id="bas_id731667571152620" localize="false"> "VarType(table)="&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/03010101.xhp#msgbox_h1"/>
</section>
</body>
</helpdocument>
|