Results 1 to 18 of 18

Thread: [RESOLVED] Very quick question - limitations of String (Plus Timer question)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Resolved [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.

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Very quick question - limitations of String

    You can use the memo field in the database

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    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?

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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.

  7. #7
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    Re: Very quick question - limitations of String

    Quote 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!

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    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

  10. #10
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    Re: Very quick question - limitations of String (Plus Timer question)

    Quote 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:
    1. Public Const msgValue = Int(frmMsgBox.Label1.Caption)
    2.  
    3. Public Function MyMsg(lMsg As String, lTitle As String)
    4.  
    5. With frmMsgBox
    6. .Caption = lTitle
    7. .labelMessage.Caption = lMsg
    8. .Show
    9. End With
    10.  
    11. 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:
    1. msgVal = MyMsg("Custom message", "Message Title")
    2.  
    3. If msgVal = 1 Then
    4. 'Do "Yes" case
    5. Else
    6. 'Do "No" case
    7. End if

  11. #11
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    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:
    1. 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:
    1. Public Function MyMsg(lMsg As String, lTitle As String) [B]As Whatever[/B]

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    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?

  13. #13
    Hyperactive Member BrendanDavis's Avatar
    Join Date
    Oct 2006
    Location
    Florida
    Posts
    492

    Re: [RESOLVED] Very quick question - limitations of String (Plus Timer question)

    Quote 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:
    1. 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:
    1. 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!

  14. #14
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    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 ^_^

  16. #16
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    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 ^_^;;

  18. #18
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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
  •  



Click Here to Expand Forum to Full Width