VisualFreeBasic代码_数值转换为字符串

2026-1-21 / 0 评论 / 40 阅读

Bin 返回一个整数的二进制,字符串表示形式

Print Bin(54321)
Print Bin(54321, 5)
Print Bin(54321, 20)
将产生输出:
1101010000110001
10001
00001101010000110001

Oct 将数字转换为八进制,字符串表示形式

Print Oct(54321)
Print Oct(54321, 4)
Print Oct(54321, 8)
将产生输出:
152061
2061
00152061

Hex 将数字转换为十六进制,字符串表示形式

Print Hex(54321)
Print Hex(54321, 2)
Print Hex(54321, 5)
将产生输出:
D431
31
0D431

Str 返回一个文本类型的数值或 Unicode 字符的文本

Dim a As Integer
Dim b As String
a = 8421
b = Str(a)
Print a, b

WStr 返回数字或ASCII字符串的宽字符字符串表示形式

Dim zs As ZString * 20
Dim ws As WString * 20
zs = "你好,世界"
ws = WStr(zs)
Print ws

Format 格式化指定格式的数字,返回 字符串

数字格式

Print Format(99100.123456, "#,##0.##")
输出:99,100.12
print format(12, "0000")
输出:0012

日期时间格式

 Format(Now, "yyyy年mm月dd日 hh时mm分ss秒")
输出:2024年09月01日 01时01分01秒

WBin 返回一个数字的二进制WString(Unicode)表示

WOct 返回一个数字的八进制WString(Unicode)表示

WHex 返回一个数字的十六进制WString(Unicode)表示

评论一下?

OωO
取消