Class implementation help please


  1.    05 Jun 2009 #1
    billymyersiii Guest

    Class implementation help please


    I am having trouble determining how to get this to work if possible. I
    need to have different class instances write html to a single class
    instance that creates one InternetExplorer.Application Window and has
    a method that captures all data from the other classes.

    Expected result is: 1 window will popup and display the text from all
    method calls th addhtml

    Dim cls1, cls2

    Set cls1 = New TestClass
    Set cls2 = New TestClass

    cls1.addhtml("<b>test1</b>")
    cls2.addhtml("<b>test2</b>")

    Class TestClass

    End Class

    Class TestClass
    addhtml("<b>test3</b>")
    End Class

    Class TestClass
    addhtml("<b>test4</b>")
    End Class

    Class TestIE
    Private oIE
    Public Function addhtml(html)
    If NOT (oIE is Nothing) Then
    Set oIE = CreateObject
    ("InternetExplorer.Application")
    oIE.visible=1
    End If
    oIE.document.write html
    End Function
    End Class
      My System SpecsSystem Spec

  2.    05 Jun 2009 #2
    Alex K. Angelopoulos Guest

    Re: Class implementation help please




    <billymyersiii@xxxxxx> wrote in message
    news:45f970d8-7a5b-46fe-a529-ea866c004cc2@xxxxxx

    > I am having trouble determining how to get this to work if possible. I
    > need to have different class instances write html to a single class
    > instance that creates one InternetExplorer.Application Window and has
    > a method that captures all data from the other classes.
    >
    > Expected result is: 1 window will popup and display the text from all
    > method calls th addhtml
    >
    > Dim cls1, cls2
    >
    > Set cls1 = New TestClass
    > Set cls2 = New TestClass
    >
    > cls1.addhtml("<b>test1</b>")
    > cls2.addhtml("<b>test2</b>")
    >
    > Class TestClass
    >
    > End Class
    >
    > Class TestClass
    > addhtml("<b>test3</b>")
    > End Class
    >
    > Class TestClass
    > addhtml("<b>test4</b>")
    > End Class
    >
    > Class TestIE
    > Private oIE
    > Public Function addhtml(html)
    > If NOT (oIE is Nothing) Then
    > Set oIE = CreateObject
    > ("InternetExplorer.Application")
    > oIE.visible=1
    > End If
    > oIE.document.write html
    > End Function
    > End Class

    Option Explicit

    Class IeWriter
    Dim MyIE
    Public Function addhtml(html)
    MyIE.document.write html
    End Function
    End Class


    Dim cls1, cls2, globalIE

    ' You want a single IE instance to be used by multiple class
    ' instances. To make it work, you need to create the IE instance
    ' in one location and ensure that apps using it have a ref
    ' to the same instance.
    ' One way that works is this.
    ' First, create a global IE object
    Set globalIE = CreateObject("InternetExplorer.Application")
    ' navigate, wait, then make it visible.
    globalIE.Navigate "about:blank"
    do while globalIE.ReadyState <> 4: WScript.Sleep 20: Loop
    globalIE.Visible = true

    ' Now create an instance of our IeWriter class:
    Set cls1 = New IeWriter
    ' The IeWriter has a public MyIE property that we can fill with
    ' our global IE instance:
    Set cls1.MyIE = globalIE

    'Now repeat for another instance of the IeWriter class:
    Set cls2 = New IeWriter
    Set cls2.MyIE = globalIE

    cls1.addhtml "<b>test1</b>"
    cls2.addhtml "<b>test2</b>"


      My System SpecsSystem Spec

  3.    09 Jun 2009 #3
    billymyersiii Guest

    Re: Class implementation help please


    I'm sorry, I currently have it working this way, but looking for a way
    to let the class(s) handle the implementation not the calling code. It
    makes no sense to implement this code every time if it is a
    requirement across all classes. That is why I am trying to move it out
    of the calling code and into the class code. It seems that everytime I
    try to do so I end up with multiple IE windows if you know what I
    mean.




    On Jun 5, 4:07*pm, "Alex K. Angelopoulos" <alex(dot) k(dot again)
    angelopoulos(at)gmail.com> wrote:

    > <billymyers...@xxxxxx> wrote in message
    >
    > news:45f970d8-7a5b-46fe-a529-ea866c004cc2@xxxxxx
    >
    >
    >
    >
    >

    > > I am having trouble determining how to get this to work if possible. I
    > > need to have different class instances write html to a single class
    > > instance that creates one InternetExplorer.Application Window and has
    > > a method that captures all data from the other classes.
    >

    > > Expected result is: 1 window will popup and display the text from all
    > > method calls th addhtml
    >

    > > Dim cls1, cls2
    >

    > > Set cls1 = New TestClass
    > > Set cls2 = New TestClass
    >

    > > cls1.addhtml("<b>test1</b>")
    > > cls2.addhtml("<b>test2</b>")
    >

    > > Class TestClass
    >

    > > End Class
    >

    > > Class TestClass
    > > * * * * * * *addhtml("<b>test3</b>")
    > > End Class
    >

    > > Class TestClass
    > > * * * * * * *addhtml("<b>test4</b>")
    > > End Class
    >

    > > Class TestIE
    > > * * * * *Private oIE
    > > * * * * *Public Function addhtml(html)
    > > * * * * * * * * *If NOT (oIE is Nothing) Then
    > > * * * * * * * * * * * * * Set oIE = CreateObject
    > > ("InternetExplorer.Application")
    > > * * * * * * * * * * * * * oIE.visible=1
    > > * * * * * * * * * End If
    > > * * * * * * * * * oIE.document.write html
    > > * * * * *End Function
    > > End Class
    >
    > Option Explicit
    >
    > Class IeWriter
    > * * * * * Dim MyIE
    > * * * * * Public Function addhtml(html)
    > * * * * * * * * * *MyIE.document.write html
    > * * * * * End Function
    > End Class
    >
    > Dim cls1, cls2, globalIE
    >
    > ' You want a single IE instance to be used by multiple class
    > ' instances. To make it work, you need to create the IE instance
    > ' in one location and ensure that apps using it have a ref
    > ' to the same instance.
    > ' One way that works is this.
    > ' First, create a global IE object
    > Set globalIE = CreateObject("InternetExplorer.Application")
    > ' navigate, wait, then make it visible.
    > globalIE.Navigate "about:blank"
    > do while globalIE.ReadyState <> 4: WScript.Sleep 20: Loop
    > globalIE.Visible = true
    >
    > ' Now create an instance of our IeWriter class:
    > Set cls1 = New IeWriter
    > ' The IeWriter has a public MyIE property that we can fill with
    > ' our global IE instance:
    > Set cls1.MyIE = globalIE
    >
    > 'Now repeat for another instance of the IeWriter class:
    > Set cls2 = New IeWriter
    > Set cls2.MyIE = globalIE
    >
    > cls1.addhtml "<b>test1</b>"
    > cls2.addhtml "<b>test2</b>"- Hide quoted text -
    >
    > - Show quoted text -
      My System SpecsSystem Spec

Class implementation help please

Similar Threads
Thread Forum
Moving from class C to class B ip address scheme, any tips(DC/DNS)
We are about to migrate away from a class C ip structure (192.168.100.x) to class B (http://www.subnet-calculator.com/subnet.php?net_class=B) I...
Server General
When a class is both an inherited class of another, and alsoimplements an interface method
The code below doesn't compile (after I added ": IComparable" on the first line). Any advice on how to get it compiled? public class...
.NET General
AHCI Implementation
I implemented AHCI on a Vista Ultimate system with three SATA drives (changed the registry to load the MSAHCI service). I think I ended up with...
Vista General
MVVM-implementation
I have tried following John Gossman's ContactDatabase-example to make a simple application to divide a two decimals, just to grasp the concept of...
Avalon
MOM.Implementation Error
After booting Vista desk top, I get following message MOM.Implementation ver 2.0.2768 could not be loaded. What is this problem, any help? --...
Vista performance & maintenance
EFI Implementation on Vista
Could it be possible to natively install Windows Vista or Windows code name Longhorn on Intel-based Mac if it implements EFI? I found some article...
Vista installation & setup
UAC - practical implementation?
Hi! I think I am missing something very basic and expected to be able to find the information I am looking for easily, but in fact, have not been...
Vista security

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 00:44.
    .