CBOOL
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgCbool
- 最后更新: 2021-10-11
将数值或字符串表达式转换为布尔型(Boolean)
语法
vb
declare function Cbool ( byval expression as datatype ) as boolean
Type typename
declare operator cast ( ) as boolean
End Type用法
vb
result = Cbool( numeric expression )
result = Cbool( string expression )
result = Cbool( user defined type )参数
expression
要转换为 Boolean 值的数值、字符串或用户自定义类型
datatype
任何数值、字符串或用户自定义类型
typename
用户自定义类型
返回值
Boolean 值。
说明
Cbool 函数将零值转换为 False,将非零值转换为 True。
函数名可以理解为"转换为布尔型"(Convert to Boolean)。
如果参数是字符串表达式,则不区分大小写地与字符串 "false" 比较返回 False 值,与 "true" 比较返回 True 值。
示例
start GeSHi
vb
' Using the CBOOL function to convert a numeric value
'Create an BOOLEAN variable
Dim b As BOOLEAN
'Convert a numeric value
b = CBOOL(1)
'Print the result, should return True
Print b
Sleepend GeSHi
版本
- 自 fbc 1.04.0 起支持
方言差异
- 在 -lang qb 方言中不可用,除非使用别名
__Cbool引用。
与 QB 的差异
- FreeBASIC 新增特性
另请参阅
CbyteCubyteCshortCushortCintCuintClngCulngClngintCulngintCsngCdblStr
返回 目录