DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: Open For Binary

  1. #1
    Join Date
    Sep 2008
    Posts
    13

    Open For Binary

    I am saving data as binary to my file, but VB6 is automatically adding some extra lines that are not in my write string. I think it is the identifier for the file type as binary if i wanted to get the file contents.. but i cannot have that line there... How do I remove it?

  2. #2
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    "some extra lines" or "one extra line" ?
    I think it's ONE only extra line, coz probably u r using "Print" for writting, use "Put" instead ..
    **When VB read a file, it doesn't read AT ALL extra lines and information needed by the OS for the file structure, it reads the contained data only; "Print" automatically put a "CR+LF" at the end of the data.
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  3. #3
    Join Date
    Sep 2008
    Posts
    13
    well, first, you could put a semi-colon at the end of the print to suppress that, and, second, it is multiple lines "08000c00" <-- as viewed in a reverse byte order hex editor in between every 2 lines of my string.

    I am using put, btw.

  4. #4
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    The Put statement only writes the number of bytes, based on the size of the variable, to the file.
    So you either have extra data in your output string, or you have another stray piece of code that is writing to your file.

  5. #5
    Join Date
    Sep 2008
    Posts
    13
    any ideas on why this code would generate data other than what i have in the text box plus string mstrcd and 0000000 & modeset?
    Last edited by cryo.burned; 09-19-2008 at 08:43 AM. Reason: Fixed Code Tags

  6. #6
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Yes, because Variants are not strings.
    Variants do include extra bytes to help describe what type of data is in them.
    Don't use binstr5, a Variant type, for output; use a string variable.
    Or better yet , change the Variants to strings and eliminate the problem completely.

    You are also using the wrong slash in your file name. It should be "\CodeList.BIN". I am surprised this did not cause an error.

    Also your code blocks should be just: code, Not code=vb

  7. #7
    Join Date
    Sep 2008
    Posts
    13
    for the code,some forums do it differently... one forum had a code=vb and it syntaxed the code and everything. but maybe i didnt get an error because my version of VBis weird. one minute some code will work and the next without changing it the same code doesnt work. its vb6 but i dont have al the vb6 commands :S

  8. #8
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by cryo.burned
    its vb6 but i dont have al the vb6 commands :S
    If you are using VB6, then you have VB6....I don't understand what you mean by this. What "commands" do you feel you are missing?

  9. #9
    Join Date
    Sep 2008
    Posts
    13
    like the command Left$ / Left

    so i can have another question about open for binary..

    issues using get. i can seem to open anything it is like this correct:

    Code:
    Dim fnum As Integer
    Dim filestr as String
    fnum = FreeFile
    Open CommonDialog1.FileName For Binary As #fnum
    Get #fnum,(starting opening position),(place to store the contents of file)
    Close #fnum
    right?

    i get an error like invalid procedure or call or the files uses an automation method visual basic does not support. How can this happen?

  10. #10
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Get in VB6

  11. #11
    Join Date
    Sep 2008
    Posts
    13
    I can use get and it opens no problem. The moment i touch the string though, it dies.
    Last edited by cryo.burned; 09-19-2008 at 08:43 AM.

  12. #12
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    What do you mean "it dies"?

  13. #13
    Join Date
    Sep 2008
    Posts
    13
    if i try to move the string into a text box, or convert it to ASCII, or anything really, my program kills itself, with error description invalid procedure or call.

  14. #14
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by cryo.burned
    if i try to move the string into a text box, or convert it to ASCII, or anything really, my program kills itself, with error description invalid procedure or call.
    What is the exact error message and error number?

  15. #15
    Join Date
    Sep 2008
    Posts
    13
    Error #5, Invalid Procedure or Call.

    Debug points to this line:
    Code:
    binset3 = binset3 & Asc(Mid(binset2, x, 1))

Similar Threads

  1. Open File Dialog and Database Location Problem
    By anthony1709 in forum .NET
    Replies: 2
    Last Post: 04-03-2007, 09:27 AM
  2. The JADE Open Framework, an open source RAD tool for the J2EE!
    By Dan Dubinsky in forum java.announcements
    Replies: 0
    Last Post: 06-27-2002, 09:02 PM
  3. Replies: 0
    Last Post: 06-08-2002, 07:51 PM
  4. list of open source projects and resources
    By Anonymous in forum Open Source
    Replies: 0
    Last Post: 05-12-2002, 09:05 PM
  5. Open source projects, open source resources
    By Anonymous in forum Open Source
    Replies: 0
    Last Post: 01-29-2002, 10:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center