Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access violation at address 0040169D...

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
Greetings all...

In Form1 I have this code in the FormCreate(...) function
Code:
        try
                {
                 // Clear and set new attributes on Form 1
                 Form1->btnSend->Caption = "Send";
                 Form1->txtServerWin->Lines->Clear();
                 Form1->txtClientWin->Lines->Clear();
                 // Clear and set new attributes on Form 2
                 Form2->lstConnected->Items->Clear();
                 Form2->lstConnected->Items->Clear();
                 Form2->txtUser->Clear();
                 Form2->txtEmail->Clear();
                 Form2->txtName->Clear();
                 Form2->txtWeb->Clear();
                 Form2->txtPassword->Clear();
                 Form2->txtPort->Text="8800";
                }
        catch(...)
                { // if (for any reason) we are unable to change ny of these
                  // attributes return a zero ('0')
                 return 0;
                }
        return 1;
and when I run it I get this error message,
Code:
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 0040169D. Read of address 000002DC'. Process stopped. Use Step or Run to continue

the error occures when I'm trying to change an attribute on Form2, why is this so?! I believe it has something to do with the fact that Form2 is not yet created at this point, am I right?! if so, where should I place this code so that it wont happen again?! or should I rewrite it, and place a similar code in Form2s' FormCreate(...)??

thanks for any help... My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Greetinx!

Usually, that exception has thrown when any pointer to object, to which you want to take access, has NULL value.
Exapmple, pointer form has NULL value in case of that form was not created nor yet or never. So, try to verify value of pointer to object where you have an exception.
Happy programming!))
 
If you didn't initialize some pointers, initialize them with null or new... at the first. John Fill
1c.bmp


ivfmd@mail.md
 
Pavlo, then it is I guessed... it was beacuse Form2 had not yet been created, thus I am unable to change what is not!! (common sense :))

I change the code, so that one part was in Form1 and the other in Form2!!

Came to think of something this second, which I should have done earlier. the Objects on Form2 has not yet been created beacuse the program will first create Form1, and on doing so I tried to change the value of an object on a form that has not yet been created!! Should be more carful and read my own code before asking for assitance! My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top