VB传文本文件问题

idhgd 2007-07-20 09:43:35
我用winsock传输文本文件,可以正确传到,可是文本的末尾总是有若干个空格.这是怎么回事,而且好像文本内容长度不一样空格的数也不一样.
...全文
189 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
idhgd 2007-07-23
  • 打赏
  • 举报
回复
已经发给你了,帮忙改改,谢谢了
QQstone 2007-07-21
  • 打赏
  • 举报
回复
stone0123210@163.com
写出问题,和传上整个工程文件,最好先压压.
idhgd 2007-07-20
  • 打赏
  • 举报
回复
或者有人愿意帮我改一下,留个E-MAIL
idhgd 2007-07-20
  • 打赏
  • 举报
回复
接收成功代码
If InStr(1, Strdata, "|COMPLETE|") <> 0 Then
frmDownloading.objProg.Value = frmDownloading.objProg.Max
MsgBox "File Received!", vbInformation, "Download Complete!"
bFileTransfer = False

Put #1, , strdata
Close #1
Unload frmDownloading
Set frmDownloading = Nothing
DoEvents

If bGettingDesktop = True Then
bGettingDesktop = False
Shell "MSPaint " & App.Path & "\desktop.bmp", vbMaximizedFocus
End If


Exit Sub
End If

发送的函数
Public Sub SendFile(fileName As String, WinS As Winsock)

Dim FreeF As Integer
Dim LenFile As Long
Dim nCnt As Long
Dim LocData As String
Dim LoopTimes As Long
Dim I As Long

FreeF = FreeFile

Open fileName For Binary As #99

nCnt = 1

LenFile = LOF(99)

WinS.SendData "|FILESIZE|" & LenFile
DoEvents

Sleep (400)


Do Until nCnt >= (LenFile)

LocData = Space$(1024) 'Set size of chunks


Get #99, nCnt, LocData 'Get data from the file nCnt is from where to start the get


If nCnt + 1024 > LenFile Then
WinS.SendData Mid$(LocData, 1, (LenFile - nCnt))
Else

WinS.SendData LocData 'Send the chunk
End If

nCnt = nCnt + 1024

Loop


Close #99

End Sub
`````````````````
*********************
If InStr(1, strData, "|GETFILE|") <> 0 Then
SendFile Mid$(strData, 10, Len(strData)), objTCP(intmax)
objTCP(intmax).SendData "|COMPLETE|"
End If
WM_JAWIN 2007-07-20
  • 打赏
  • 举报
回复
长度剪切不对!
fxy_2002 2007-07-20
  • 打赏
  • 举报
回复
代码?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧