Results 1 to 15 of 15

Thread: How can I store a large string in visual basic 6 (in runtime?)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195

    How can I store a large string in visual basic 6 (in runtime?)

    I want to have a standalone exe that has a large string (~1mb) of data. What is the best way to do this?
    The textbox has a limit of ~65000 characters.. and you cannot simply write in the IDE
    someString = 1mbworthofdata

    How can you store a large string in a program without having to resort to loading the data from a file?

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: How can I store a large string in visual basic 6 (in runtime?)

    A String can hold around ~1GB-2GB of data maximum. Read it here: http://www.vbforums.com/showthread.p...-string-in-VB6


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: How can I store a large string in visual basic 6 (in runtime?)

    I think he wants a control to avoid asigning the String to the variable in code, if so, you can place as many text as you want in a the RichTextBox Control, quick test with 5 million chars:
    Code:
    rtb.Text = String(5000000, "A")
    Last edited by jcis; Nov 15th, 2012 at 10:28 PM.

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: How can I store a large string in visual basic 6 (in runtime?)

    Technically even if you have the data embedded in the exe you are still going to be loading it from a file, it just happens to be the same file that contains the exe

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195

    Re: How can I store a large string in visual basic 6 (in runtime?)

    datamiser: but how would i read it?
    jcis: id like to do that but i dont want to add another reference/ocx to the richtextbox
    akhileshbc: i know a string can load that large amount of data, but how would i do that without a textfile?

    any other ideas?

  6. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: How can I store a large string in visual basic 6 (in runtime?)

    What is your exact requirement ? Do you want to keep a big data that you generated in your program till the program terminates ? Or is it like you want to read the big data for some manipulation in your program? Or is it like you want to display it to the user ?

    If your requirement is to read the data and do some manipulations using it, then try this idea:
    If your data has a specific structure, then you could keep the data in a file and use the Random Access mode to read specific records from the file. That is to read a specific data, seek to the record to which you want to read, then read the record. If you want to change, then change it and so on.

    Read this: http://www.thevbprogrammer.com/Ch06/...andomFiles.htm


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195

    Re: How can I store a large string in visual basic 6 (in runtime?)

    i dont want to use a file though - i just want one standalone exe

  8. #8
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: How can I store a large string in visual basic 6 (in runtime?)

    Quote Originally Posted by qpabani View Post
    i dont want to use a file though - i just want one standalone exe
    If you wish to distribute your application as a single EXE file, then you could try embedding it to your application resource. Then at runtime, extract it to a temp location and use that file. After use, remove the file from the temp location.

    Read this: http://www.thevbzone.com/l_res.htm


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  9. #9
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How can I store a large string in visual basic 6 (in runtime?)

    You can put your data into a file, and then use this file as the basis for a Custom resource during development. Use the LoadResData() function at runtime to retrieve it into a dynamic Byte array.

    If it is really text and limited to ANSI or the ASCII subset, you can save space by creating your file as ANSI and after loading it from the resource use StrConv() to translate it to Unicode for use and assign it to a String. If it is text but Unicode, you can omit conversion but you may have to skip over the BOM if you have one:

    Code:
        'Examples showing the use of custom "text" resources.  Here
        'I just use them to fill two TextBox controls:
        
        'Notepad and most Windows editors don't create a BOM for ANSI
        'files since there isn't one defined.  So the entire resource
        'consists of ANSI text:
        Text1.Text = StrConv(LoadResData("ANSI", "TEXT"), vbUnicode)
        
        'UTF-16LE "Unicode" text files normally have a 2-byte BOM.
        'If we used Notepad to create this resource we'll want to
        'strip it here:
        Text2.Text = Mid$(LoadResData("UNICODE", "TEXT"), 2)
    For binary data just assign to a dynamic Byte array.

  10. #10
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,948

    Re: How can I store a large string in visual basic 6 (in runtime?)

    Don't work with a Byte addressed data type. Just use a String, so then Dim your variable as a String, then you will then be able to make it possible to store up to a whopping 1Gb of ASCII data...
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  11. #11
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How can I store a large string in visual basic 6 (in runtime?)

    Theimp - follow the bouncing ball.. in order to assign it to the string, it has to BE SOMEWHERE FIRST... and that's what the OP is trying to figure out...

    Personally, I vote for the embedded resource, extract, read method... but at the same time... I gotta wonder ... what kind of string data is that large?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How can I store a large string in visual basic 6 (in runtime?)

    I'm guessing the next question will end up being "How to update?" the resource at runtime.

    There usually just isn't a good reason to load up an EXE with large blobs of data like this anyway.

  13. #13
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,948

    Re: How can I store a large string in visual basic 6 (in runtime?)

    You can also attach a String together, using this following example:
    Code:
    Dim String1 As String
    Dim String2 As String
    .
    .
    .
    frmMain.Text1.Text = String1 & " " & String2
    This will then be able to give you a 1Gb plus more of the data, that you can display, but not store inside the very same variable. Just you have to make them String data types. In which you are able to have a 1Gb of data inside them each. Thus totalling up to 2Gb in size...
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

  14. #14
    Addicted Member
    Join Date
    Oct 2012
    Posts
    137

    Re: How can I store a large string in visual basic 6 (in runtime?)

    use mdb to store data

  15. #15
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,948

    Re: How can I store a large string in visual basic 6 (in runtime?)

    Yes ofcourse a data base is able to store even more data that 1Gb...
    I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...

    |Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |

    Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...

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