09-05-13, 03:01 AM
السلام عليكم شباب
عندي كود ارسال ملف بالينسوك ولاكن عندة ارسال الملف يظهر خطء ولا اعرف ماهوة السبب اتمنا المساعدة
صوؤة للخطء
![[صورة مرفقة: x8gO3-T3cS_566639025.jpg]](http://www.iraqup.com/up/20130509/x8gO3-T3cS_566639025.jpg)
الكود
عندي كود ارسال ملف بالينسوك ولاكن عندة ارسال الملف يظهر خطء ولا اعرف ماهوة السبب اتمنا المساعدة
صوؤة للخطء
![[صورة مرفقة: x8gO3-T3cS_566639025.jpg]](http://www.iraqup.com/up/20130509/x8gO3-T3cS_566639025.jpg)
الكود
كود :
Dim sending As Boolean
Public Sub Wait(iSecond As Integer)
On Error Resume Next
Dim tme As Single
tme = Timer
Do Until (Timer - tme >= iSecond) Or sending = True
DoEvents
Loop
End Sub
Private Sub Command1_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Command2_Click()
SendFile Text1.Text
End Sub
Private Sub SendFile(pPath As String)
Dim ia As Long
On Error GoTo Down:
Dim I As Long
Dim B() As Byte
'==============
If Form1.Winsock1.State = 7 Then
sending = False
DoEvents
Wait (5)
End If
Open pPath For Binary As #1
For I = 1 To LOF(1)
If Loc(1) >= LOF(1) Then
GoTo Down:
Exit Sub
End If
If Form1.Winsock1.State <> 7 Then
GoTo Down:
Exit Sub
End If
If LOF(1) < 1024 * 8 Or LOF(1) - Loc(1) < 1024 * 8 Then
ReDim B(LOF(1) - Loc(1) - 1)
Else
ReDim B(1024 * 8 - 1)
End If
Get #1, , B
sending = True
Form1.Winsock1.SendData "A" & "|" & B
DoEvents
Wait (5)
Next
Down:
Close #1
End Sub