请帮我修改个错误,同时看看我的代码还有什么问题
以下是我写的发送文件的一段代码,其中协议只是给每一包文件加了个表示长度的头,还没有写完,
提示错误出现在 Get #intfilenumber, , bytfilebuffer(intfilelenth)语句 错误为“变量使用了一个vb不支持的自动化类型”, 我不知道是怎么回事 求大哥大姐帮帮忙指点指点!
Public Sub FileSendManager(filename As String)
Dim byttest(8) As Byte
Dim bytSend() As Byte
Dim intSendLen As Long
Dim intfilelenth As Long
Dim filebuffer() As Byte
Dim intfilenumber As Integer
Dim intfilecount As Integer, i As Integer, j As Integer
Dim lperunit As Long
lperunit = 10
filename = Form3.Text1.Text
intfilenumber = FreeFile
Open filename For Binary As intfilenumber '打开文件
intfilelenth = LOF(intfilenumber) '获得文件长度,以字节为单位
ReDim bytfilebuffer(intfilelenth)
Get #intfilenumber, , bytfilebuffer(intfilelenth) '将文件读入缓冲区
If intfilelenth < lperunit Then
MsgBox "文件太小!"
End If
'根据每一块大小获取总包数
If CInt(intfilelenth / lperunit) > intfilelenth / lperunit Then
intfilecount = CInt(intfilelenth / lperunit)
Else: intfilecount = CInt(intfilelenth / lperunit) + 1
End If
For i = 0 To intfilecount - 1
'帧头需修改
byttest(0) = i \ 1000 '组织帧头
byttest(1) = (i Mod 1000) \ 100
byttest(2) = (i Mod 1000 Mod 100) \ 10
byttest(3) = i - byttest(0) * 1000 - byttest(1) * 100 - byttest(2) * 10
byttest(4) = intfilecount \ 1000
byttest(5) = (intfilecount Mod 1000) \ 100
byttest(6) = (intfilecount Mod 1000 Mod 100) \ 10
byttest(7) = intfilecount - byttest(4) * 1000 - byttest(5) * 100 - byttest(6) * 10
Form1.MSComm1.Output = byttest '发送数据
ReDim bysend(lperunit)
For j = 0 To lperunit - 1
bysend(j) = bytfilebuffer(i * lperunit + j)
Form1.MSComm1.Output = bysend
Next
Next
End Sub