2013-11-02 92 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