none
晕了在异步内AddressOf 使用条件语句失效.. RRS feed

  • 问题

  • 在线等!!!!!

    例如: 
    Imports System
    Imports System.Net
    Imports System.Text
    Imports System.Threading
    Imports System.IO
    Imports System.Data
    Imports System.Data.SqlClient
    Public Class Form1
    
        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim http As Net.WebRequest = Net.WebRequest.Create("http://www.baidu.com")
            http.Method = "GET"
            http.BeginGetResponse(AddressOf cs, http)
            Dim http2 As Net.WebRequest = Net.WebRequest.Create("http://www.hao123.com")
            http2.Method = "GET"
            http2.BeginGetResponse(AddressOf cs, http2)
        End Sub
        Sub cs(ByVal ai As IAsyncResult)
            Control.CheckForIllegalCrossThreadCalls = False
            Dim State3 As Net.WebRequest = ai.AsyncState
            Dim Response3 As Net.WebResponse = State3.EndGetResponse(ai)
            Dim url = Response3.ResponseUri.AbsoluteUri
            Dim Stream3 As StreamReader
            Stream3 = New StreamReader(Response3.GetResponseStream, Encoding.UTF8)
            Dim html = Response3.ResponseUri.AbsoluteUri & Stream3.ReadToEnd
            TextBox1.Text = url
            If url = "http://www.baidu.com" Then
                MsgBox("baidu")
            ElseIf url = "http://www.hao123.com" Then
                MsgBox("hao123")
            End If
        End Sub
    End Class
    
    2009年4月2日 8:02

答案

全部回复