![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | Re: Class implementation help please <billymyersiii@xxxxxx> wrote in message news:45f970d8-7a5b-46fe-a529-ea866c004cc2@xxxxxx Quote: > 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 Specs![]() |
| | #3 (permalink) |
| | 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: Quote: > <billymyers...@xxxxxx> wrote in message > > news:45f970d8-7a5b-46fe-a529-ea866c004cc2@xxxxxx > > > > > Quote: > > 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. Quote: > > Expected result is: 1 window will popup and display the text from all > > method calls th addhtml Quote: > > Dim cls1, cls2 Quote: > > Set cls1 = New TestClass > > Set cls2 = New TestClass Quote: > > cls1.addhtml("<b>test1</b>") > > cls2.addhtml("<b>test2</b>") Quote: > > Class TestClass Quote: > > End Class Quote: > > Class TestClass > > * * * * * * *addhtml("<b>test3</b>") > > End Class Quote: > > Class TestClass > > * * * * * * *addhtml("<b>test4</b>") > > End Class Quote: > > 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 Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| When a class is both an inherited class of another, and alsoimplements an interface method | .NET General | |||
| MOM.Implementation file | Vista performance & maintenance | |||
| EFI Implementation on Vista | Vista installation & setup | |||
| UAC - practical implementation? | Vista security | |||