Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

vb6 - write data to image

Hello there,
I have this code that is working just fine but I found a little thing that I want to change
if the picture.jpg is already there and the size is 300KB when I download a new picture
with size of 10KB the size stays at 300KB... I wonder why is this happening? how can I prevent this?
                
                Dim Pos%, Length%, HEAD$, MyFileNumber As Long
                
                Pos = InStr(Text1.Text, vbCrLf & vbCrLf)
                Length = Len(Text1.Text)
                HEAD = Left(Text1.Text, Pos - 1)
                Text1.Text = Right(Text1.Text, Length - Pos - 3)
                Open App.Path & "\picture.jpg" For Binary Access Write As #1
                Put #1, , Text1.Text
                Close #1

Open in new window

Avatar of CSecurity
CSecurity
Flag of Iran, Islamic Republic of image

You store binary and image data into textbox??? Store them into string and write to file from string, not using Textbox control. That will be slower and for sure you'll lose a lot of data.
Avatar of XK8ER

ASKER

well thats not the problem here the problem is the size of the image being the same
If you use textbox you have size limit, which is about 300KB. If you are sure problem isn't textbox, paste here entire code.
Avatar of XK8ER

ASKER


    Dim Data As String
    Dim Pos%, Length%, HEAD$, MyFileNumber As Long
    
    Pos = InStr(Data, vbCrLf & vbCrLf)
    Length = Len(Data)
    HEAD = Left(Data, Pos - 1)
    Data = Right(Data, Length - Pos - 3)
    Open App.Path & "\picture.jpg" For Binary Access Write As #1
    Put #1, , Data
    Close #1

Open in new window

When you add new data to Data variable and what do you have in Textbox (Text1)? I'm sure problem is because of Textbox. Anyway, where you set data to Data variable? It isn't complete code. In this code no any flaw exists, flaw or error is in somewhere else.
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of XK8ER

ASKER

thanks a lot PaulHews... thats exactly what i looking for..