admin 管理员组

文章数量: 887021


2023年12月17日发(作者:下载postgresql文件夹)

To use OnReadyStateChange in a Visual Basic application1. Open Microsoft® Visual Basic® 6.0. In the New Project dialog box, double-click Standard EXE.2. On the Project menu, click References.3. In the Available References list, select Microsoft XML,v6.0, and then click OK.4. Add four command buttons to Form1 and set the caption of each button as follows:TABLE 1ControlCommand1Command2Command3Command4CaptionFailPolling using TimerUsing Class WrapperUsing DOMDocument5. Add a timer control to Form1.6. Copy and paste the following code into Option ExplicitPublic XMLHttpRequest As P60Public WithEvents XMLDom As ument30Private Function FunctionReadyStateChange() tateEnd FunctionPrivate Sub Command1_Click() FailedOnReadyStateEnd SubPrivate Sub Command2_Click() TimerResolutionEnd SubPrivate Sub Command3_Click() ClassResolutionEnd SubPrivate Sub Command4_Click() DOMResolutionEnd SubPrivate Sub FailedOnReadyState()On Error GoTo FailedState If Not XMLHttpRequest Is Nothing Then Set XMLHttpRequest = Nothing Set XMLHttpRequest = New P60 ' Assign the wrapper class object to onreadystatechange. yStateChange = FunctionReadyStateChange ' Get some stuff asynchronously. "GET", "localhost/", True

Exit SubFailedState: MsgBox & ": " & ptionEnd SubPrivate Sub TimerResolution() If Not XMLHttpRequest Is Nothing Then Set XMLHttpRequest = Nothing al = 1 Set XMLHttpRequest = New P60 ' Get some stuff asynchronously. "GET", "localhost/", True d SubPrivate Sub ClassResolution() If Not XMLHttpRequest Is Nothing Then Set XMLHttpRequest = Nothing Dim MyOnReadyStateWrapper As MyReadyStateHandler Set XMLHttpRequest = New P60 ' Create an instance of the wrapper class. Set MyOnReadyStateWrapper = New MyReadyStateHandler ' Assign the wrapper class object to onreadystatechange. yStateChange = MyOnReadyStateWrapper ' Get some stuff asynchronously. "GET", "localhost/", True d SubPrivate Sub DOMResolution() If Not XMLHttpRequest Is Nothing Then Set XMLHttpRequest = Nothing If Not XMLDom Is Nothing Then Set XMLDom = Nothing Set XMLDom = New ument30 = True "localhost/"End SubPrivate Sub Timer1_Timer() tate If tate = 4 Then MsgBox "Done" al = 0 End IfEnd SubPrivate Sub XMLDom_onreadystatechange() tate If tate = 4 Then MsgBox "Done" End IfEnd Sub7. From the Project menu, click Add Class Module.

8. Change the name of the new class module from "Class1" to "MyReadyStateHandler"9. Paste the following code into the class module:VBCopyOption ExplicitSub OnReadyStateChange() tate If tate = 4 Then MsgBox "Done" End IfEnd Sub10. In the sample code added in the previous step, highlight the procedure name "OnReadyStateChange" by selectingit in the Code window.11. From the Tools menu, click Procedure the Procedure Attributes dialog, the Name combo box should show "OnReadyStateChange."12. Click Advanced.13. In Procedure ID, select "(Default)" from the available options.14. Click OK.15. Save the class module () to file.16. Open Notepad and paste the following XML into itXMLCopy This is to test the onreadystatechange event on the XMLHTTPRequest or DOMDocument This is due to the event not being declared in the type library17. Save the file as to your IIS localhost directory. For example, this folder might be C:Inetpubwwwroot fora typical default installation of IIS with Windows 2000.18. In Visual Basic, from the Run menu, click Start to run the application.19. Try the following command options to observe the different approaches to using the onreadystatechange eventwithin Visual Basic.1. To force a ready state failure, click Fail.2. To view the polling resolution, click Polling using Timer.3. To view the wrapper class solution, click Using Class Wrapper.4. To view the DOMDocument approach, click Using DomDocument.20. For each of the code paths in the previous step, you can place brake-points at various places to step through thecode.


本文标签: 文件夹 作者 下载