必须固定String的长度! 而且最好不要用String 会存在ANSI+DBCS<->UniCode的转换问题 应该用Byte数组 Private Type TrainerStandings sETrainerName(1 to 10) As Byte sCTrainerName(1 to 10) As Byte iTotal_Started As Integer i1st As Integer i2nd As Integer i3rd As Integer i4th As Integer i5th As Integer iTotal_Starteds As Integer cPrize_Won As Currency End Type 读写文件示例:读取: Dim TempFile As Long Dim LoadBytes() As ByteTempFile=FreeFile Open 文件名 For Binary As #TempFile Redim LoadBytes(1 To Lof(TempFile)) As Byte Get #TempFile,,LoadBytes Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)写入: Dim TempFile As Long Dim SaveBytes() As ByteSaveBytes=StrConv(Text1.Text,vbFromUniCode)TempFile=FreeFile Open 文件名 For Binary As #TempFile Put #TempFile,,SaveBytes Close TempFile
而且最好不要用String
会存在ANSI+DBCS<->UniCode的转换问题
应该用Byte数组
Private Type TrainerStandings
sETrainerName(1 to 10) As Byte
sCTrainerName(1 to 10) As Byte
iTotal_Started As Integer
i1st As Integer
i2nd As Integer
i3rd As Integer
i4th As Integer
i5th As Integer
iTotal_Starteds As Integer
cPrize_Won As Currency
End Type
读写文件示例:读取:
Dim TempFile As Long
Dim LoadBytes() As ByteTempFile=FreeFile
Open 文件名 For Binary As #TempFile
Redim LoadBytes(1 To Lof(TempFile)) As Byte
Get #TempFile,,LoadBytes
Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)写入:
Dim TempFile As Long
Dim SaveBytes() As ByteSaveBytes=StrConv(Text1.Text,vbFromUniCode)TempFile=FreeFile
Open 文件名 For Binary As #TempFile
Put #TempFile,,SaveBytes
Close TempFile