I'm trying to view youtube captcha in my vb application but I don't know how to refresh/redraw the picture box. The youtube captcha is in http://www.youtube.com/cimg and the captcha is changing everytime I refresh the page. How can I do that using button or timer in vb.net to change the captcha. Here is the code I used to load the captcha to picturebox.
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
i try to use captchaBox.Refresh() but it's not working. I hope someone can help me. thx
Refresh just redraws the control, it doesn't retrieve the image again. You need to reset the ImageLocation property for it to work. For example with a timer:
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
Try this:
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
Related
I've noticed something when I use Mousehover event, that it is slower in some milliseconds.
I mean that when I point my cursor on it, it is few milliseconds slower. please help me How to fix this
Here's my code:
Public Class Form1
Private Sub Button1_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseHover
Button1.ForeColor = Color.White
End Sub
Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseLeave
Button1.ForeColor = Color.Black
End Sub
End Class
Please help me.
use MouseMove event instead of MouseHover, that will do it for you. It gives you an immediate response.
Code:
Private Sub Button1_MouseMove(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseMove
Button1.ForeColor = Color.White
End Sub
Best wishes!
-BHARATHI Tutorials
So I make a form like this
Form1
The picture box will show neutral.png when form is loaded, so
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox1.Image = Image.FromFile("Images\neutral.png")
End Sub
I make the image on picturebox1 change to x.png while mouse over and disappear when mouse leave, so
Private Sub PictureBox1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseEnter
PictureBox1.Image = Image.FromFile("Images\x.png")
End Sub
Private Sub PictureBox1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.MouseLeave
PictureBox1.Image = Image.FromFile("Images\neutral.png")
End Sub
My question is how I make the x.png image stay on the picturebox1 when I click the picturebox1. Doing this
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
PictureBox1.Image = Image.FromFile("Images\x.png")
End Sub
Doesn't seem work since the mouseleave event still have an effect.
There is example, from my comment
Public Class Form1
Private isClicked As Boolean = False
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
PictureBox1.Image = Image.FromFile("images\neutral.jpg")
End Sub
Private Sub PictureBox1_Click(sender As Object, e As System.EventArgs) Handles PictureBox1.Click
If isClicked = False Then isClicked = True Else isClicked = False 'if You click again, everything back
'isClicked = True 'in this case, when You click "x.jpg" will stay always
PictureBox1.Image = Image.FromFile("images\x.jpg")
End Sub
Private Sub PictureBox1_MouseEnter(sender As Object, e As System.EventArgs) Handles PictureBox1.MouseEnter
If isClicked = False Then 'picturebox isn't clicked, so show x.jpg ... otherwise x.jpg will be showed always
PictureBox1.Image = Image.FromFile("images\x.jpg")
End If
End Sub
Private Sub PictureBox1_MouseLeave(sender As Object, e As System.EventArgs) Handles PictureBox1.MouseLeave
If isClicked = False Then 'picturebox isn't clicked, so show neutral image ... otherwise x.jpg will be showed always
PictureBox1.Image = Image.FromFile("images\neutral.jpg")
End If
End Sub
End Class
Use some variable, in this example is isClicked.
Always make checking under MouseEnter and MouseLeave is picturebox clicked or not.
By this example, You can click again on picturebox to, let's say, reset that isClicked, so You can have again neutral and x images.
I have two forms in my application, form2 is shown on clicking a button in the form1. but i need a delay of 7 seconds between form1's close and form2's show for that i wrote the following code:
Public Class Form1
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = 0
Me.Close()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
i += 1
If i = 7 Then
Form1.Show()
End If
End Sub
End Class
But it does not give me the result. form2 not shown at all. what was the mistake i had made in the code? can anyone help me?
Thanks in advance.
When there's no active form left in a Windows Forms application, the application will quit. Therefore, you might want to hide the main form instead of closing it:
Me.Hide()
i think no need of unnecessary declaration for time delay because you can simply set it on your timer control itself
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = 7000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Form2.Show()
Me.Close()
End Sub
End Class
or
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = 7000
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Close()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Form2.Show()
End Sub
So I nailed the ability to drag a picturebox around the Windows form. I need it to hide itself when it's dragged and dropped over another picture. I've tried a few methods but none seem to work and I am now back at square one, the only code I have is so that I can move the picturebox around the form.
I Solved Your Problem
Here Is How The Form Should Look Like
And Here Is The Code I Made:
Private Sub CheckTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckTimer.Tick
CheckTimer.Stop()
CheckTimer.Interval = 1
If PictureBox2.Location = New System.Drawing.Point(TextBox1.Text, TextBox2.Text) Then
PictureBox2.Visible = False
End If
CheckTimer.Start()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = PictureBox1.Location.X
TextBox2.Text = PictureBox1.Location.Y
CheckTimer.Start()
End Sub
Hope This Code Was Helpful To You.
I made an better code than the old one, try it.
Here Is How The Form Should Look Like:
and here is the code :
Public Class Form1
Dim Point As New Point
Dim X, Y As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
Timer1.Interval = 1
Point = Cursor.Position
PictureBox2.Location = New System.Drawing.Point(Point.X - X, Point.Y - Y)
Timer1.Start()
End Sub
Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
X = Cursor.Position.X - PictureBox2.Location.X
Y = Cursor.Position.Y - PictureBox2.Location.Y
Timer1.Start()
End Sub
Private Sub PictureBox2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseUp
Timer1.Stop()
If PictureBox2.Location.X < PictureBox1.Size.Width Then
PictureBox2.Visible = False
End If
End Sub
End Class
I hope this code was useful to you.
i have two RadioButtons one for Light Blue and the other for Ghost White and a button to show the next Form (Form2)
i want to be able to check on a Radio Button and the backcolor of form2 changes to the checked Radio Button
this is what i have on my coding so far
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
SecondForm.Show()
End Sub
Private Sub rbLightBlue_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbLightBlue.CheckedChanged
If rbLightBlue.Checked Then
SecondForm.BackColor = (Color.LightBlue)
End If
End Sub
Private Sub rbGhostWhite_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbGhostWhite.CheckedChanged
If rbGhostWhite.Checked Then
SecondForm.BackColor = (Color.GhostWhite)
End If
End Sub
The problem am having is making the background color change on Form2.
Any answer for this question will be very helpful.
I am not sure what you are doing, it probably has to do with how you are creating your SecondForm, this code does work, see if it helps you narrow it down.
Public Class Form1
Dim SecondForm As Form2 = New Form2
Private Sub rbLightBlue_CheckedChanged(sender As Object, e As EventArgs) Handles rbLightBlue.CheckedChanged
If DirectCast(sender, RadioButton).Checked Then
SecondForm.BackColor = Color.LightBlue
End If
End Sub
Private Sub rbGhostWhite_CheckedChanged(sender As Object, e As EventArgs) Handles rbGhostWhite.CheckedChanged
If DirectCast(sender, RadioButton).Checked Then
SecondForm.BackColor = Color.GhostWhite
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
SecondForm.Show()
End Sub
End Class