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
版权声明:本文标题:VBXMLHTTP异步调用 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1702793495h431168.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论