Board index » cppbuilder » Access Violation in TListbox->Items->Strings when the Item is a verylong string
kiko
![]() CBuilder Developer |
Sun, 03 Apr 2005 22:59:42 GMT
|
kiko
![]() CBuilder Developer |
Sun, 03 Apr 2005 22:59:42 GMT
Access Violation in TListbox->Items->Strings when the Item is a verylong string
Hi,
Quote> int linesToGo = lstDiscussion->Count/3; define these Strings one time before the loop ? AnsiString UserName, Date, Message; for (...) { ... Quote} Message) ? Quote> Acces violation at adres 000000003e. Read of adres 0000000003e. |
nws
![]() CBuilder Developer |
Sun, 03 Apr 2005 23:34:10 GMT
Re:Access Violation in TListbox->Items->Strings when the Item is a verylong stringQuotekikof wrote: - Hide quoted text - - Show quoted text - Quote>AnsiString UserName, Date, Message; The exception occurs in this line! Quote>>Acces violation at adres 000000003e. Read of adres 0000000003e. |
kiko
![]() CBuilder Developer |
Mon, 04 Apr 2005 04:03:25 GMT
Re:Access Violation in TListbox->Items->Strings when the Item is a verylong stringI've tried your code and I get no error with it (9 TListBox lines filled) : lstDiscussion->Items->Strings[8] = AnsiString::StringOfChar('A',2000); // You have to look for bugs in another parts of your code I think. |
nws
![]() CBuilder Developer |
Mon, 04 Apr 2005 05:39:06 GMT
Re:Access Violation in TListbox->Items->Strings when the Item is a verylong stringPlease use the lstDiscussion->Items->Add method to add them first. The following string gave me the error (one line!): When you instantiate a Visual Basic component from an Active Server Quotekikof wrote: |
nws
![]() CBuilder Developer |
Mon, 04 Apr 2005 07:31:07 GMT
Re:Access Violation in TListbox->Items->Strings when the Item is a verylong stringPlease use the lstDiscussion->Items->Add(aMessage); method to add it first and let aMessage be the 3d item you add string. The following string gave me the error (one line!): When you instantiate a Visual Basic component from an Active Server So could you please rewrite it like: lstDiscussion->Items->Add("test"); Quotekikof wrote: > > lstDiscussion->Items->Strings[8] = AnsiString::StringOfChar('A',2000); // >enough long, isn't it ? > int linesToGo = lstDiscussion->Items->Count/3; > for (int i=0;i<linesToGo;i++) { > AnsiString UserName = lstDiscussion->Items->Strings[i*3+0]; > AnsiString Date = lstDiscussion->Items->Strings[i*3+1]; > AnsiString Message = lstDiscussion->Items->Strings[i*3+2]; > } > >You have to look for bugs in another parts of your code I think. > > > |
kiko
![]() CBuilder Developer |
Tue, 05 Apr 2005 04:44:43 GMT
Re:Access Violation in TListbox->Items->Strings when the Item is a verylong stringI not forgot you but I haven't BCB at office. Quote> lstDiscussion->Items->Add("test"); After that, I copied/pasted your long line at the place of AnsiString::StringOfChar('A',2000). I added \ at each end of code line in order to make it a valid string. Again this works perfectly. You have to believe me when i tell you there is a bug somewhere else in your program. Just create like me an another project for testing this very thing. An unlucky use of a pointer several lines before can do that, for sure... I ever saw something like that in some of my programs. A bug that it was coded several days before suddenly appears in another program part just because the memory you take at this time is committed by the bug (a pointer story in general). |
nws
![]() CBuilder Developer |
Tue, 05 Apr 2005 07:18:52 GMT
Re:Access Violation in TListbox->Items->Strings when the Item is a verylong stringThanks for the tip, but I cannot reproduce this using a new application. Somehow I've gotten some weird TString at that current Item, because even the de{*word*81} and watch window hangs when I try to get the content of that item. The strange thing, I am now looking for, how did I get this weird string there in the first place? I have got not clues where to look for now. Anyhow thanks alot for all your help. Quotekikof wrote: |
nws
![]() CBuilder Developer |
Wed, 06 Apr 2005 07:21:28 GMT
Re:Access Violation in TListbox->Items->Strings when the Item is a verylong stringHi, please check the message with the subject: " Brain braker in TListbox->Add causes a Access Violation in 0000003e. Please help me.... " for a follow up. I created a new discussion so that more people can help me. |
1. Access Violation in TListbox->Items->Strings when the Item is a very long string
2. ComboBox1->Items->Strings[DayOfWeek(Date())];
3. ListView => items.item[?].caption question
4. Are there any items in: CheckListBox1->Items ??
5. TComboBox->Items->Objects[] woes
6. TListView->Items->Clear() is deadly slow
7. ListView->Items->Clear() question.
8. TListView->Items->Add() bug (2)
9. TListview->Items->Add() bug ? BCB4
10. Using TListBox->TopIndex property instead of TListBox->Selected