Can I reference a VBScript class inside another VB

Results 1 to 2 of 2

Thread: Can I reference a VBScript class inside another VB

  1. #1
    Join Date
    Dec 1969

    Default Can I reference a VBScript class inside another VB

    I&#039;m working on a calendaring app for my employer. I&#039;ve got a database of users and events and projects.<BR><BR>I started using VBScript classes through Server-Side Includes to encapsulate the functionality I need.<BR><BR>The "CalendarEvent" class will be the "basic" class for this app. For each "CalendarEvent" object, I will need to reference an Employee and possibly a Project. I wanted to write an "Employee" class and a "Project" class, but I&#039;m having trouble working it out. <BR><BR>In my "CalendarEvent" can the properties of my CalendarEvent class be other "class" objects? In other words, can I have an "Employee" property that would contain the correct Employee object? If so, how would I reference this information (mycalendarevent.employee.first_name)?<BR><BR>Than ks-<BR><BR><BR>Greg<BR>

  2. #2
    Join Date
    Dec 1969

    Default Of course...

    ...why didn&#039;t you just try it???<BR><BR>Class Employee<BR>&nbsp; &nbsp; public first_name, last_name, emp_num<BR><BR>&nbsp; &nbsp; public Function showInfo()<BR>&nbsp; &nbsp; &nbsp; &nbsp; showInfo = last_name & ", " & first_name & " (" & emp_num & ")"<BR>&nbsp; &nbsp; End Function<BR><BR>End Class<BR><BR>Class CalendarEvent<BR>&nbsp; &nbsp; public theDate<BR>&nbsp; &nbsp; public theEmployee<BR><BR>&nbsp; &nbsp; public Sub SetEvent( dt, emp )<BR>&nbsp; &nbsp; &nbsp; &nbsp; theDate = dt<BR>&nbsp; &nbsp; &nbsp; &nbsp; Set theEmployee = emp <BR>&nbsp; &nbsp; End Sub<BR>End Class<BR><BR>... mainline code ...<BR><BR>Set theEmp = new Employee<BR>theEmp.first_name = "John"<BR>theEmp.last_name = "Doe"<BR>theEmp.empnum = 7713<BR><BR>Set theEvent = new CalendarEvent<BR>theEvent.SetEvent( Date()+3, theEmp )<BR><BR>...<BR><BR>Response.Write "Employee " & theEvent.theEmployee.showInfo() & " has an event on " & theEvent.theDate<BR><BR>...<BR>%&#062;<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