Results 1 to 7 of 7

Thread: vb6 richtextbox max length

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    vb6 richtextbox max length

    I have a rich text box that is only saving around 80 characters. The database I am using is Excel. I can go to Excel and type in 500 characters and the rich text box in my program will display it. but if I enter more then about 80 characters in the rich text box it won't make it to excel. I have the max length set to "0" and that doesn't work. I have set it at 500 and 1000 and it still kicks out anything larger then 80 characters. I have set the max length in code

    RichTextBox1.MaxLength = 1000

    it still won't save anything more then 80 characters. What could I be doing wrong.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: vb6 richtextbox max length

    Quote Originally Posted by Honsolo View Post
    What could I be doing wrong.
    Using Excel as a "database"? (it very definitely isn't, and if you are using database related code that could be the cause)

    Another strong possibility is that you have made a mistake somewhere in the code that saves the data... but as you haven't shown it to us, we can't tell.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Re: vb6 richtextbox max length

    Might be best if I attack this myself. Everyone tells me not to use Excel however I have to for this application and it's a very small database. I am also using a dao data control. Something everyone tells me not to do. However I am using many very small databases and so far the program has worked perfect.

    I don't have code used to save the database because the data control auto saves on exit or when refreshed.

    If I use any other data control I have hours and hours of coding to do and in all my efforts so far, I have not been able to get them to work. So I stick to the dao. You would think Microsoft could come up with a data control that actually works without 50 lines of specific code like the dao data control.

    I will with draw my question as I'm sure it will only result in everyone wasting time slamming me for my decisions.

    Thank you for your time

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Re: vb6 richtextbox max length

    OK I found a fix, How ever I don't know why.
    I went to my Excel database and opened the "Notes" field up to about 100 characters wide and 20 rows deep, then I placed a period at the beginning and ran spaces to about 90 characters and put another period. Now I can put all the text I want wherever I want to and the program saves everything perfect. I think what I did flipped a switch in Excel that is allowing me to have max text entry. Does anyone know if the switch I tripped can be done with code.
    Thank you for your time

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: vb6 richtextbox max length

    Quote Originally Posted by Honsolo View Post
    Everyone tells me not to use Excel however I have to for this application and it's a very small database.
    The size of the file is not important, the problem is that it is not a database - which is the cause of the problem.

    However, if you have to use it then you will have to deal with the extra problems it creates.
    If I use any other data control I have hours and hours of coding to do
    Using another type of data control would not mean more code (the entire point of a control is that you don't need code).

    Not using a control would mean more code, but not much more effort - and there are many working examples that you can copy and paste (just changing the table/field names etc), such as the ADO Tutorial from our DB FAQs (link to both in my signature).
    Quote Originally Posted by Honsolo View Post
    OK I found a fix, How ever I don't know why.
    I went to my Excel database and opened the "Notes" field up to about 100 characters wide and 20 rows deep, then I placed a period at the beginning and ran spaces to about 90 characters and put another period.
    That is one of the common problems caused by treating a data file as a database - because unlike a database the file does not have any indication of what data types each "field" is, and therefore a guess needs to be made instead.
    Does anyone know if the switch I tripped can be done with code.
    Not easily.

    There is a way to make the data-type guess use more rows from the existing data to improve its accuracy (and damage the speed), but that will only work if you have existing data that suits your maximum size - and it also needs a per-machine registry setting (which you need admin rights to change, and it could break other programs).

    What you could do is use automation (which needs Excel to be installed) to add an extra row at the top of the file, and then remove that row once your program has connected to the data. This will be awkward due to the potential file lock conflict, an will be even more awkward because you are using a data control.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Re: vb6 richtextbox max length

    Thank you Si
    That was very good info. Much better then what I have receive in the past. My employer wanted to use excel because of data corruption in the past where data was lost. So instead of building one large data base, I have each of the customers orders in it own excel spread sheet that is saved to their individual folder. Then I have a small data base of the file locations. If there is a corruption it will only effect one excel file and not the whole database. Also each file can be read outside my program. It is also easier for archiving and the program will be as fast in 2 years as it is today when it's new. I was told VB2010 is much better with databases. I need this one on line now but plan to rewrite in in 2010 at a later date. Maybe 2 years when the upgrade will be necessary. Again thank you for the explanation. To many so called programmers have lots of smart a** advice but can't give you an answer to your question. You spelled it out nicely.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: vb6 richtextbox max length

    Quote Originally Posted by Honsolo View Post
    My employer wanted to use excel because of data corruption in the past where data was lost. So instead of building one large data base, I have each of the customers orders in it own excel spread sheet that is saved to their individual folder. Then I have a small data base of the file locations. If there is a corruption it will only effect one excel file and not the whole database.
    That is a rather odd choice... it would be far better to implement a backup system instead, as that would mean that any corruption would be recoverable.

    If a proper database system was being used, the backup options included with it would do the job nicely.

    Without a database system you should use some other backup method.
    Also each file can be read outside my program.
    That is a valid reason, and I can't think of a simple alternative at the moment.
    It is also easier for archiving and the program will be as fast in 2 years as it is today when it's new.
    Unless you have huge amounts of data per day, there would be virtually no speed loss with a database over that period (assuming the database tables etc are designed properly).

    Archiving is debatable, with a database it might take more work up front (or less, depending on the circumstances), but can then be fully automatic after that.
    Again thank you for the explanation. To many so called programmers have lots of smart a** advice but can't give you an answer to your question. You spelled it out nicely.
    No problem... but note that giving you advice to change tools/methods is often far better than giving you the answer you want.

    It usually means a temporary halt to your work while you get/learn the new thing, but it can save you time quickly. As an example, one program I wrote took 3 days in VB6 (which I had been using for over 10 years), but in VB2008 (which I hadn't used before) it took less than 2 days, plus made the future requirements far easier to implement.

    Unless you explain valid reasons for using 'bad' tools (in terms of the data control you definitely haven't), it is perfectly understandable that people will suggest alternatives that are known to be better in most cases.
    Last edited by si_the_geek; Sep 8th, 2010 at 08:41 AM.

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