Option Strict On
Public Class frmStatus
Inherits System.Windows.Forms.Form
Public Overloads Sub Show(ByVal Message As String)
lblStatus.Text = Message
Me.Show()
Application.DoEvents()
End Sub
End Class
The functions
Dim StopThread As Boolean = True 'Global Variable
Private Sub button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim t As New System.Threading.Thread(AddressOf DisplayStatus)
StopThread = False
t.Start()
conn.SqlConnection1.Open()
'ur connectivity code goes here............
conn.SqlConnection1.Close()
StopThread = True
t.Abort()
End Sub
Public Sub DisplayStatus()
Dim frmStatusMessage As New frmStatus()
'Change these values accordingly
frmStatusMessage.ProgressBar1.Maximum = 10
frmStatusMessage.ProgressBar1.Minimum = 1
frmStatusMessage.ProgressBar1.Step = 1
frmStatusMessage.Show("Connecting to SQL Server")
Dim counter As Integer = 0
While Not StopThread
frmStatusMessage.ProgressBar1.Value = counter
counter += 1
System.Threading.Thread.Sleep(10) 'change this value accordingly
End While
If StopThread Then
frmStatusMessage.Close()
End If
End Sub