Teen Programmers Unite  


Return to forum top

VB Class Help! URGENT!

Posted by Brok3n_Link [send private reply] at August 07, 2002, 08:46:09 AM

hey all, need help with a VB class. I get an error "Object Variable or With Block variable not Set" error when I try and run a project with a class in it. The class handles Variables, and events when those variables change. It gives error when any of the variables change or are read\used:
(variable = player1.score), but instead, stops and gives the error. I really need help for this, It is a big project and has to be done by Monday(is now Wednessday night). so why does this error occur and how do i fix it. thanx.

Posted by eXorcus [send private reply] at August 07, 2002, 11:57:30 AM

When you make the class, you have to SET it after DIMing it.
I think this code is proper, if not, check the MSDN on the SET command:

Dim player1 as CPlayer
Set player1 = new CPlayer

You should then be able to access the class' properties through player1.score
Could also be just putting the NEW the other way 'round IE:

Dim player1 as new CPlayer
Set player1 = CPlayer

Posted by Brok3n_Link [send private reply] at August 08, 2002, 07:47:40 AM

uh yeah, where do i put this?
i'm at school at the moment, so i can't test anything, but just wondering so i can get right into it when i get home.

You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.