2013-11-02 99 views
0

我想查看youtube captcha在我的vb應用程序,但我不知道如何刷新/重繪圖片框。 YouTube的驗證碼位於http://www.youtube.com/cimg,每次刷新頁面時驗證碼都會更改。我如何使用vb.net中的按鈕或計時器來更改驗證碼。這是我用來將驗證碼加載到圖片框的代碼。在VB.net刷新或重繪圖片盒

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     captchaBox.ImageLocation = "http://www.youtube.com/cimg" 
    End Sub 

我嘗試使用captchaBox.Refresh(),但它不工作。我希望有一個人可以幫助我。 thx

回答

0

刷新只是重繪控件,它不會再次檢索圖像。您需要重置ImageLocation屬性才能使其工作。例如用定時器:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
    captchaBox.ImageLocation = "http://www.youtube.com/cimg" 
    Timer1.Enabled = True 
    Timer1.Interval = 1000 
End Sub 

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 
    captchaBox.ImageLocation = "http://www.youtube.com/cimg" 
End Sub 
0

試試這個:

Private Sub Form1_Load() Handles MyBase.Load 
    Timer1.Start() 
    PictureBox1.ImageLocation = "http://www.youtube.com/cimg" 
End Sub 

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick 
    PictureBox1.Image = Nothing 
    PictureBox1.ImageLocation = "http://www.youtube.com/cimg" 
End Sub