Skip to content

InputB, InputB$

返回从以InputBinary模式打开的文件中读取的固定数量字节。

语法:

  • InputB( Number , [ # ] FileNumber ) --- 返回Variant
  • InputB$( Number , [ # ] FileNumber ) --- 返回一个String,其底层字节即为读取到的字节。
Number
必需 要返回的字节数。
FileNumber
必需 用于以Open语句打开文件的文件号。

InputBInput的面向字节版本。Input计算和返回字符(在twinBASIC的UTF-16缓冲区中每个字符两个字节),而InputB计算和返回原始字节——当通过文本方式打开的通道读取二进制数据时非常有用。

字节在打包到结果中时不会进行任何字符集转换;String形式只是将字节序列重新解释为UTF-16字符串进行存储。

示例

vb
Dim Bytes As Variant
Open "data.bin" For Binary Access Read As #1
Bytes = InputB(LOF(1), 1)            ' Read the whole file as bytes.
Close #1

另请参阅

twinBASIC及其LOGO版权为作者"韦恩"所有