Creating object within a VBscript class

Results 1 to 4 of 4

Thread: Creating object within a VBscript class

  1. #1
    Jon Guest

    Default Creating object within a VBscript class

    Can anyone tell me why this would not work?<BR><BR>Class Validate<BR><BR> Private Sub Class_Initialize()<BR> Dim CheckName<BR> Dim CheckAddress<BR> Dim CheckCity<BR> Dim CheckZip<BR> Dim CheckCountry<BR> Dim CheckPhone<BR> Dim CheckEmail<BR> Dim CheckCreditCard<BR> Dim XCheck<BR> Set XCheck = Server.CreateObject("SMUM.XCheck.1")<BR> End Sub<BR><BR> Public Property Get CheckName(Value) <BR> If XCheck.IsValidName(value) Then<BR> CheckName = True<BR> Else<BR> CheckName = False<BR> End If<BR> End Property<BR><BR>....<BR><BR>The error is this:<BR><BR>Microsoft VBScript runtime error &#039 800a01a8&#039 <BR><BR>Object required: &#039XCheck&#039 <BR><BR>/jontest/Validate.asp, line 18 <BR><BR><BR>If I move the XCheck createobject lines out of the class, everything works fine. It needs to be called from within the class. I have tried taking it out of the initialize routine as well.<BR><BR>Thanks,<BR> Jon

  2. #2
    Bill J Guest

    Default RE: Creating object within a VBscript class

    Move the function XCheck from a private function to a public function. This should resolve the issue...<BR><BR>If not then post the code for validate.asp<BR><BR>

  3. #3
    Jon Guest

    Default RE: Creating object within a VBscript class

    I made the initialize function public but it didn&#039t fix the problem. The code that was listed there was the part of validate.asp that is causing the problem.

  4. #4
    Join Date
    Dec 1969

    Default RE: Creating object within a VBscript class

    Don&#039t you have a major goof in that class?<BR><BR>You have all those variables Dim&#039ed inside the initialize function. They should be declared in the class body, not inside the function.<BR><BR>That is:<BR><BR>Class Validate<BR><BR>Dim CheckName<BR>Dim CheckAddress<BR>Dim CheckCity<BR>Dim CheckZip<BR>Dim CheckCountry<BR>Dim CheckPhone<BR>Dim CheckEmail<BR>Dim CheckCreditCard<BR>Dim XCheck<BR><BR>Private Sub Class_Initialize()<BR>&nbsp;&nbsp;&nbsp;&nbsp;Set XCheck = Server.CreateObject("SMUM.XCheck.1")<BR>End Sub<BR><BR>...<BR><BR>************<BR><BR>Not sure that helps what you are trying to do, but hard for me to see how what you have could ever work.<BR><BR>Am I missing something big? <BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts