Results 1 to 20 of 20

Thread: Opening a file more than 1Meg in size,plz...thanks

  1. #1

    Thread Starter
    Lively Member mrdarkwarez's Avatar
    Join Date
    Feb 2000
    Location
    Australia
    Posts
    113

    Talking

    How do i open a file more than 1meg in size and display its contents in a textbox??

    much appreciated!!

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    A textbox can't display that much text. It's not the buffer, it's because it can't reference that high a number. You'd need to use a RichTextBox instead.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Be sure to...

    ...open the file in binary mode

    http://www.vb-world.net/files/openstatement/
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Addicted Member
    Join Date
    Feb 2000
    Location
    London, UK
    Posts
    145
    ...or using the command
    Text1.Loadfile ("C:\largefile.txt")

    I know this is (for some reason) not so popular among many programmers, but it works well for me.
    Wilhelm Tunemyr,
    Swede in London

    [email protected]

    "Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
    Heinrich Heine (1797-1856)

    Pravda vítezi!
    (Truth prevails!)

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    nah...

    The reason I told him to use Binary mode is because I heard it was alot faster than the other methods, ok, your's is easier but for large files I believe it's better to use Binary, and it sounds cool
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6

    Thread Starter
    Lively Member mrdarkwarez's Avatar
    Join Date
    Feb 2000
    Location
    Australia
    Posts
    113
    the textbox doesn't have a method call loadfile


    i got an error message trying
    Text1.Loadfile("C:\somelargefile.txt")


  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    It's meant for the RichTextBox from Microsoft (Press CTRL + T) and add it to your project.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8

    Thread Starter
    Lively Member mrdarkwarez's Avatar
    Join Date
    Feb 2000
    Location
    Australia
    Posts
    113

    Talking oh....

    one last things.. how much data can the rich text box hold...

    in other words.. is there a limit on the file size i can display in the RTB?

    Much Appreciated

  9. #9
    Guest
    I think its 2 or 3 gigabytes....

  10. #10
    Hyperactive Member Asaf_99's Avatar
    Join Date
    Jul 2000
    Location
    Israel
    Posts
    335
    I think that 2-3 GB is enough and nobody enters that much text.

    every char on a textbox is one Byte, so imagine 1 MB is 10000000 Bytes, so it's like 10000000 characters. 1000 MB is 1000 MB. so it's 100000000000 characters. Times 3 it's 300000000000 characters, and that's a lot!

    Summary:
    1 Byte = 1 Char
    1 MB = 10000000 Chars
    1 GB = 10000000000 Chars
    3 GB = 30000000000 Chars
    30000000000 chars is a lot!!!

    More posts for me!
    Asaf Sagi

    ICQ: 61917199
    E-Mail: [email protected]

  11. #11
    Addicted Member
    Join Date
    Feb 2000
    Location
    London, UK
    Posts
    145
    Originally posted by Jop
    The reason I told him to use Binary mode is because I heard it was alot faster than the other methods
    Well, I use RichTexBox and LoadFile, and it only took a few seconds to open a Mp3-file of 3800 kB.
    So it's fast enough.
    Pentax
    Wilhelm Tunemyr,
    Swede in London

    [email protected]

    "Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
    Heinrich Heine (1797-1856)

    Pravda vítezi!
    (Truth prevails!)

  12. #12
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Well, I use RichTexBox and LoadFile, and it only took a few seconds to open a Mp3-file of 3800 kB.
    So it's fast enough.
    Ohh it probably uses Binary mode too then

    Sorry for the incovidence...
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  13. #13
    Addicted Member
    Join Date
    Feb 2000
    Location
    London, UK
    Posts
    145
    it probably uses Binary mode too then
    Well, that's of course possible.
    I thought of Open file As Binary and all that stuff when you wrote open in binary mode.
    What does incovidence mean?
    Pentax
    Wilhelm Tunemyr,
    Swede in London

    [email protected]

    "Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
    Heinrich Heine (1797-1856)

    Pravda vítezi!
    (Truth prevails!)

  14. #14

    Binary mode speed

    You try loading a file byte by byte from a file nto RAM - It's very slow

  15. #15
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Well, that's of course possible.
    I thought of Open file As Binary and all that stuff when you wrote open in binary mode.
    What does incovidence mean?
    Pentax
    I meant the LoadFile method, I mentioned Open File ... As Binary before. That was not what I meant mate
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  16. #16
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Question

    Originally posted by Asaf_99

    Summary:
    1 Byte = 1 Char
    1 MB = 10000000 Chars
    1 GB = 10000000000 Chars
    3 GB = 30000000000 Chars
    30000000000 chars is a lot!!!
    You're wrong.
    1 char = 8 bits
    8 bits = 1 byte
    1024 bytes = 1 KB
    1,048,576 bytes = 1 MB(1024 KB)
    1,073,741,824 bytes = 1 GB(1024 MB)
    1,099,511,627,776 bytes = 1 TeraByte(TB, 1024 GB)
    You get the picture I hope.
    1024 / 8 = 128
    multiples of two!
    128 / 2 = 64
    62 / 2 = 32
    ..16
    ..8
    ..4
    ..2
    ..1
    If it were:
    1000 / 8 = 125
    125 / 2 = 62.5
    you can't have 62.5 bits!

  17. #17
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    1 char = 8 bits
    8 bits = 1 byte
    So that'll make 1 Char = 1 byte Isn't that the same as Asaf_99 said?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  18. #18
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Yes, 1 character is 1 byte, but 1000 bytes is not a kilobyte, it takes 1024 byte to make a kilobyte.

  19. #19
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Yeah I overlooked that part in his post, sorry!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  20. #20
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    On type names:

    4 bits = 1 nibble
    2 nibbles = 1 byte

    And here's the explanation for why a text-box can't load more than 64K:
    The text box is one of the original Windows controls, and as such, is 16bit. This means it can only address a maximum of 2^16 bytes = 65536 bytes. The RichTextBox is 32bit, so it can use 2^32 bytes = 4294967296 bytes (4 gigs).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width