本人写了段程序,目的是向原来数据库中的数据(2进制的)前插加一段6个字节的数据(2进制),,插加的部分程序目的是为了达到从一个文件中取得文件的后缀名,然后判断它的长度,(指定给后缀名的长度为5个字节)后缀名长度不足的时候用0补足~~,然后转化成2进制插入到原SQL数据库数据中。(6字节安排是 开头一定为0,然后在0后面接上 补0的5个字节的后缀名)。望请大侠指点,修改,万分感谢!
Dim strExName As String
Dim strFileName As String
Dim lngDot As Long
Dim aa As Long
'获取文件后缀名 sFilePath = m_sDriver + ":\" + m_sFloder + "\" + m_aFileList(i)
MsgBox sFilePath
lngDot = InStrRev(sFilePath, ".")
If lngDot > 0 Then
strExName = Right(sFilePath, Len(sFilePath) - lngDot + 1)
MsgBox sFilePath
i = Len("strExName")
MsgBox i
n = 5 - iFor i = 0 To n
i = i & "0"
NextOpen strExName For Binary Access Read As #lFreeFile
Get #lFreeFile, , aa
m_objRecords.Fields(sFileFiled).AppendChunk 0
m_objRecords.Fields(sFileFiled).AppendChunk aa
Dim strExName As String
Dim strFileName As String
Dim lngDot As Long
Dim aa As Long
'获取文件后缀名 sFilePath = m_sDriver + ":\" + m_sFloder + "\" + m_aFileList(i)
MsgBox sFilePath
lngDot = InStrRev(sFilePath, ".")
If lngDot > 0 Then
strExName = Right(sFilePath, Len(sFilePath) - lngDot + 1)
MsgBox sFilePath
i = Len("strExName")
MsgBox i
n = 5 - iFor i = 0 To n
i = i & "0"
NextOpen strExName For Binary Access Read As #lFreeFile
Get #lFreeFile, , aa
m_objRecords.Fields(sFileFiled).AppendChunk 0
m_objRecords.Fields(sFileFiled).AppendChunk aa
strExName = left(strExName,5)
不要用循环了
如果是从后面补足:
strExName = strExName & "00000"
strExName = left(strExName,5)