When your computer is running a procedure (Subroutine or Function) any events that are triggered while its running are placed into a cue and will run in the order they were called AFTER the procedure completes.
When you set the progress bar visible property to true you end up triggering several events which relate to redrawing / repainting the form and its controls on the screen. As you have found out these events are not run until the current procedure finishes and allows the code to branch away and execute the next waiting procedure..
You have two options.
1.) Call the My.Application.DoEvents method periodically from within your running procedure. Upon calling this method you will allow the code execution to branch away and execute another procedure (such as refreshing the screen via a repaint) if one or more are awaiting execution. Upon completion of these outstanding events control is returned to your procedure where it continues to run to completion or handline of another DoEvents call.
To allow the animation of the progress bar to function you would also have to periodacially call DoEvents from within a loop. A Do/While Loop that loops while the connection is NOT open and has a means of terminating the loop via a counter is very easy to code.
2.) The other way is to start another thread that runs independently of the main program. This new thread will handle the display of a progress bar on a new form.
edit:
Here is an example of using a timer to update a counter variable which in turn is used to control a Do/While Loop.
The code would other wise enter an infinite loop were it not for the use of a DoEvents call which allows the code to branch away and handle the timer TICK event which increments the counter variable .
To make this loop more effective for your code you would exit this loop when the connect becomes open OR when the loop times out .
Public Class Form1
Private m_cntLimit As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TimeLimit As Integer
pbarProgress.Visible = True
m_cntLimit = 0
TimeLimit = 120
Do While m_cntLimit < TimeLimit
My.Application.DoEvents()
Label1.Text = m_cntLimit
Loop
MsgBox("end")
pBarProgress.Visible = False
End Sub
Private Sub tmrLimit_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrLimit.Tick
'timer is enabled and set for an interval of 250
m_cntLimit = m_cntLimit + 1
End Sub
End Class