我正在尝试在我的vb应用程序中查看youtube验证码,但我不知道如何刷新/重绘图片框。 youtube验证码位于http://www.youtube.com/cimg,每次刷新页面时验证码都会发生变化。如何使用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 :(得分: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
答案 1 :(得分: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