How can I make sure a transfer through winsock is complete before trying to use the file?

I wrote a program that will take the screenshot of a remote computer screen and send it to me over winsock.  The problem is, it tries to display the image before the transfer is complete.  On the server side, I have the following code:

keybd_event vbKeySnapshot, 1, 0&, 0&
SavePicture Clipboard.GetData(vbCFBitmap), "c:\sht.bmp"
Dim Efile As String
Open "c:\sht.bmp" For Binary As #1
Efile = Space(LOF(1))
Get #1, 1, Efile
Close #1
frmServer.tcpserver.SendData Efile

(plus the required function declarations), and on the client side, I have

tcpclient.GetData strdata
Open "c:\screenshot.bmp" For Binary As #1
Put #1, , vardata
Close #1
frmSShot.imgssht.Picture = LoadPicture("c:\screenshot.bmp")

the problem is, when it tries to load the picture, only a small portion of the file is present (4~8kB) out of 275kB or so, so an error occurs.  How can I make sure the entire file is transferred and written before displaying the picture?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try specifying the type and size of the data...
I know that there's a "bytesTotal" parameter on the DataArrival Event. you could use that

tcpclient.GetData strdata, vbString, bytesTotal.

darkshadow88Author Commented:
I tried that, and it doesn't work.  I noticed that the screenshot.bmp file that is generated is always either 4.27kB or 8.00kB; never more than that.  Could my problem have to do with limitations on string length, and if so, how could I get around it?
Here is an example of file transfer with progress bar indication. You should read at the server side, the event DataArrival

~ fantasy ~

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

what you should do is this:
for the sending program define a boolean = true when you start sending the picture
then on the winsock_sendcomplete sub do an if then statement

If bPicSending = true then
  winsock.send "Complete"
  bPicSending = false
end if

then on the recieving side wait until you get that "Complete" message or something similar to display the image.
darkshadow88Author Commented:
Thank you!  That worked perfectly!

thanks for that.
~ fantasy ~
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.