|
-
Nov 23rd, 2006, 07:34 PM
#1
Thread Starter
Lively Member
[RESOLVED] Code Help
Hello, I'm trying to write a code by working off of a source I've been looking at, but I really have no idea what I'm doing. I would appreciate it if somebody could help me correct my code and possibly explain to me why it was not working and answer the questions i have posted in the code, or just refer me to a tutorial that could help me, Thank you .
My code is:
Code:
Dim strjpg as string
Dim strjpgcode as string
Dim strsize as string
Dim strtarget as string
strsize = 20480 'what is this for? why is it significant?
strjpg = Text1.Text
Open strjpg For Binary As #1
strjpgcode = Input$(LOF(1), 1) 'what is LOF(1),1) ?
strcount = Mid(strjpgcode, 1, strsize)
Close #1
Open strtarget For Output As #1
Print #1, strcount
Close #1
End Sub
This is supposed to take a jpg and then insert the hex into another jpg file with nothing in it, and basically make it the same. But for some reason (i think it has to do with the strsize) the target picture is missing it's bottom half. Thanks for any help!
-
Nov 24th, 2006, 01:24 PM
#2
Thread Starter
Lively Member
Re: Code Help
*BUMP* Can anybody please help me with this?
-
Nov 24th, 2006, 04:43 PM
#3
Re: Code Help
Welcome to the forums
As you seem to be making a copy of the first file why not use the below?
VB Code:
FileCopy "C:\File1.jpg", "File2.jpg"
I modified your code so it will copy the entire file.
VB Code:
Dim strjpg As String
Dim strjpgcode As String
Dim strsize As Double
Dim strtarget As String
Dim strcount As String
strjpg = Text1.Text
Open strjpg For Binary As #1
'LOF returns the size of the file you want to copy.
strsize = LOF(1) '20480 'what is this for? why is it significant?
' Input$(LOF(1), 1) returns the entire file into a string
strjpgcode = Input$(LOF(1), 1) 'what is LOF(1),1) ?
strcount = Mid(strjpgcode, 1, strsize)
Close #1
Open strtarget For Output As #1
Print #1, strcount
Close #1
-
Nov 24th, 2006, 05:31 PM
#4
Thread Starter
Lively Member
Re: Code Help
Thank you! The reason I'm doing it that way is because I am actually trying to take this from two different files, and then put it into one file. I understand what I'm doing now, but I still can't get this new code to work.
Code:
Dim strjpg As String
Dim strjpgcode As String
Dim strsize As String
Dim strrar As String
Dim strrarcode As String
Dim strtarget As String
Dim strtargetcode As String
Dim strsize2 As String
Dim strcount As String
Dim strcount2 As String
strjpg = Text1.Text
Open strjpg For Binary As #1
strsize = LOF(1)
strjpgcode = Input$(LOF(1), 1)
strcount = Mid(strjpgcode, 1, strsize)
Close #1
strtarget = Text3.Text
Open strtarget For Output As #1
Print #1, strcount
Close #1
strrar = Text2.Text
Open strrar For Binary As #2
strsize2 = LOF(2)
strrarcode = Input$(LOF(2), 2)
strcount2 = Mid(strrarcode, 1, strsize2)
Close #2
Open strtarget For Output As #2
Print #2, strcount2
Close #2
End Sub
What ends up happening is the second file that I am copying completely overwrites the first. I am trying to just add the second file to the end of the first one. Can you possibly help me with this? I'll continue to try while I wait for a response. Thanks again for all your help!
-
Nov 24th, 2006, 05:34 PM
#5
Re: Code Help
Open it in the Append instead of Output mode
-
Nov 24th, 2006, 05:38 PM
#6
Thread Starter
Lively Member
Re: Code Help
Thank you gavio! That's exactly what I needed, it works perfectly now. Thanks to everybody that helped me!
-
Nov 24th, 2006, 08:02 PM
#7
Re: [RESOLVED] Code Help
Welcome!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|