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?
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
:wave:
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")
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
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?
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
:wave:
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
Re: How can I store a large string in visual basic 6 (in runtime?)
Quote:
Originally Posted by
qpabani
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
:wave:
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.
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...
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? :eek2:
-tg
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.
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...
Re: How can I store a large string in visual basic 6 (in runtime?)
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...