-
Oct 9th, 2006, 06:10 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Very quick question - limitations of String (Plus Timer question)
Hi all,
Just a quick question - is there a limit as to how much data can be stored in a "String" type? I need to load the contents of a multi-line text box into a variable, and contents could span many pages. Would there be a better 'type' to store this kind of data, rather than string, or is string fine for this job?
Thanks!
Last edited by BubbleLife; Oct 9th, 2006 at 08:20 AM.
-
Oct 9th, 2006, 06:12 AM
#2
Re: Very quick question - limitations of String
You can use the memo field in the database
-
Oct 9th, 2006, 06:13 AM
#3
Re: Very quick question - limitations of String
Fixed Length Strings have a 64K limit. What are you doing with this text that requires the entire thing to be stored in a string?
-
Oct 9th, 2006, 06:14 AM
#4
Thread Starter
Addicted Member
Re: Very quick question - limitations of String
Ah, it's not for a database, it's for a regular program. The data is taken from a simple text box and stored in a variable, to be output later
EDIT:
Hack - it takes in some notes written by the user, and stores them away, ready to be output later on. But they cannot be saved to disk, since the program needs high security, so it stores them internally within the program, and outputs them later when the user logs in correctly. The program never saves any files to the disk, closing the program loses the notes, that's the idea of the program
Last edited by BubbleLife; Oct 9th, 2006 at 06:17 AM.
-
Oct 9th, 2006, 08:20 AM
#5
Thread Starter
Addicted Member
Re: Very quick question - limitations of String
Another quick question - I have a timer running on the form, but when a Msgbox is generated, it stops the timer. Is there any way of making the timer stuff run in the background whilst the Msgbox is up?
-
Oct 9th, 2006, 08:26 AM
#6
Re: Very quick question - limitations of String (Plus Timer question)
Strings FAQ - the maximum number of characters is equal to maximum amount of memory in a 32-bit computer: 4GB (of course the number of characters is half of that as one character takes two bytes).
Do you have a sample of the data? Is it just regular text or...?
On the other question, you must make your own message box.
-
Oct 9th, 2006, 08:40 AM
#7
Hyperactive Member
Re: Very quick question - limitations of String
Originally Posted by Arby
Another quick question - I have a timer running on the form, but when a Msgbox is generated, it stops the timer. Is there any way of making the timer stuff run in the background whilst the Msgbox is up?
As far as I know, not with the standard MsgBox function. They display the same as showing a vbModal form, so it's going to take priority over anything else going on. I may be wrong, though, I don't have much expeience with windows msgbox's. I created my own standard msgbox a long time ago, less confusing for me!
-
Oct 9th, 2006, 09:54 AM
#8
Re: Very quick question - limitations of String (Plus Timer question)
If you can store the text in a text box, keep it in a text box - but one whose Visible attribute is set to False.
As far as the timer running during a MsgBox, make your own message box (Form, label, 2 buttons) and show it non-modally.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Oct 9th, 2006, 11:28 AM
#9
Thread Starter
Addicted Member
Re: Very quick question - limitations of String (Plus Timer question)
Merri - Well, I can't show you the data, since it's just a textbox for users to input their own text. But now much they put in is up to them; I don't want it to crash if they decide to write an essay in there XD
BrendanDavis - Ahh ok, no worries. I've already written a lot of the code around it though, so I might just put a lable on the form instead. I *could* make a messagebox but that would be another form and that might lead to confusing problems when I try and pass the result back to the existing form ^_^;;
Al42 - Unfortunatally I can't, since it is on a seperate form. Maybe I'll set a max character limit of a few thousand characters on the notes box..
Thanks for all the help people
-
Oct 9th, 2006, 12:00 PM
#10
Hyperactive Member
Re: Very quick question - limitations of String (Plus Timer question)
Originally Posted by Arby
Merri - Well, I can't show you the data, since it's just a textbox for users to input their own text. But now much they put in is up to them; I don't want it to crash if they decide to write an essay in there XD
BrendanDavis - Ahh ok, no worries. I've already written a lot of the code around it though, so I might just put a lable on the form instead. I *could* make a messagebox but that would be another form and that might lead to confusing problems when I try and pass the result back to the existing form ^_^;;
Al42 - Unfortunatally I can't, since it is on a seperate form. Maybe I'll set a max character limit of a few thousand characters on the notes box..
Thanks for all the help people
Passing the result of a custom message box back anywhere isn't hard at all. Create a function that retrives the value of the messagebox after a button has been clicked. For example, a form with 2 buttons: yes and no. Then create a function, something similar to the custom message box function, and have it retrive some value that gets set when the "yes" or "no" buttons are pressed. For example:
custom message box function
VB Code:
Public Const msgValue = Int(frmMsgBox.Label1.Caption)
Public Function MyMsg(lMsg As String, lTitle As String)
With frmMsgBox
.Caption = lTitle
.labelMessage.Caption = lMsg
.Show
End With
End Function
Then, in the custom message box's Form_Unload, have it send an integer value depending on what they press(i.e. if the click "yes", set Label1.Caption = 1, if "no" then Label1.Caption = 2)
That way when you call the MyMsg function, you can do it like so:
VB Code:
msgVal = MyMsg("Custom message", "Message Title")
If msgVal = 1 Then
'Do "Yes" case
Else
'Do "No" case
End if
-
Oct 9th, 2006, 12:07 PM
#11
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
i haven't read this thread - these are just some comments on your code Brendan:
this will never compile - functions / properties aren't constant expressions
VB Code:
Public Const msgValue = Int(frmMsgBox.Label1.Caption)
you just wrote a post which mentioned the importance of typing, but yet haven't done so to your function:
VB Code:
Public Function MyMsg(lMsg As String, lTitle As String) [B]As Whatever[/B]
-
Oct 9th, 2006, 12:12 PM
#12
Thread Starter
Addicted Member
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
Woah - lots of information there. Thanks for the advice, but I've already built it into my form now. I'll post the program when it's complete so you can all see what I'm going on about XD.
A couple of people have said different things regarding the length of strings - One mention that it is 64K (Kilobytes?), and that it is half of the RAM. What do you think would be a good max char limit for the note box, just in case? 50,000 characters?
-
Oct 9th, 2006, 12:38 PM
#13
Hyperactive Member
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
Originally Posted by bushmobile
i haven't read this thread - these are just some comments on your code Brendan:
this will never compile - functions / properties aren't constant expressions
VB Code:
Public Const msgValue = Int(frmMsgBox.Label1.Caption)
you just wrote a post which mentioned the importance of typing, but yet haven't done so to your function:
VB Code:
Public Function MyMsg(lMsg As String, lTitle As String) [B]As Whatever[/B]
Indeed I do make errors. I'm at work and don't have VB here with me to test out things. I'm also swapping between doing work, Photoshop, e-mail, and this site as well, lol. Good catch on that. The way I have my message box function setup is a tad bit more complex than that, but it works. Trying to explain/ype it out in a matter of a minute or two in between doing 5 other things is bound to cause me to make some errors :P
I will post a sample function when I get a chance(when I get home). Something a tad more elaborate and functional. Thanks!
-
Oct 9th, 2006, 12:43 PM
#14
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
From what I've read, strings can hold up to about 2 GB of data.
As for the MsgBox question, you could create your own using a form, or run the the MsgBox in a different thread.
Although adding multi-threading to your application is overkill if it will just be used to display one message box.
-
Oct 9th, 2006, 01:06 PM
#15
Thread Starter
Addicted Member
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
Thank you for all the advice people! However, the program is done now.
For anyone who may be interested, the program is now released and can be downloaded from my "Various Creations" page (see sig), or THIS Direct link.
I have done something a bit different with the "About" screen than I usually do as well; I've merged it with the loader screen. I've also added "Thank-yous" to all the people who have helped me with advice for my program. If you don't want to be on the list, please pop me a PM or reply here and I'll take you off the list ^_^
-
Oct 9th, 2006, 02:13 PM
#16
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
Just so you know in the future, Arby, if you're writing code in Form1, you can say Form2.Text1.Text to reference a control on another form. It doesn't matter whether the control is on another form as long as it's in the same program. (It gets a little more difficult if it's on a form in a different program, but it can still be done.)
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Oct 9th, 2006, 03:48 PM
#17
Thread Starter
Addicted Member
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
OH! That's really useful, thanks a lot for that!
Right now I have been creating global boolean variables in modules and using them as a switch that changes something on form activate. Heh, I remember before I knew about modules, I used to write a file to the C:\ drive, then check for it in the other form and use that as a switch, deleting the file after the switch had been set ^_^;;
-
Oct 9th, 2006, 09:40 PM
#18
Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)
Actually, I think storing information in a separate data dedicated (class) module is better than storing information on forms. Especially on projects that are bigger than small. Makes life easier in the long run as you don't need to know which form holds what information. And you can unload forms from memory to minimize the memory usage.
Even though there is a lot of memory in computers these days, you shouldn't rely on that: and it is no excuse for writing worse code than in the old days.
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
|