Here is a very imp code
and runs smoothly for me.....
================================== Code is here =====================
Take a DataGridView use this code as it is...
here label2 is used like a Progress bar for the users
you can type anything in this label to show users
Sub Import()
Try
Label2.Show()
Dim opn As New OpenFileDialog
opn.InitialDirectory = "c:\"
opn.Title = "Open a MST/CSV Files"
opn.Filter = "CSV Files(*.csv)|*.csv|MST Files(*.MST)|*.MST"
opn.ShowDialog()
'============= Only file name without Extension===============
myfile = System.IO.Path.GetFileNameWithoutExtension(opn.FileName)
'==========================================================
Mydb = opn.SafeFileName ' file name with extension
path = opn.FileName ' full path
TextBox2.ForeColor = Color.Black
TextBox2.BackColor = Color.Yellow
TextBox2.Text = path
If TextBox2.Text = "" Then
MsgBox("Error.............Please Select Any File", CType(MsgBoxStyle.Question + MsgBoxStyle.OkOnly, MsgBoxStyle))
TextBox2.Focus()
Return
End If
Label2.Hide()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
and runs smoothly for me.....
================================== Code is here =====================
Take a DataGridView use this code as it is...
here label2 is used like a Progress bar for the users
you can type anything in this label to show users
Sub Import()
Try
Label2.Show()
Dim opn As New OpenFileDialog
opn.InitialDirectory = "c:\"
opn.Title = "Open a MST/CSV Files"
opn.Filter = "CSV Files(*.csv)|*.csv|MST Files(*.MST)|*.MST"
opn.ShowDialog()
'============= Only file name without Extension===============
myfile = System.IO.Path.GetFileNameWithoutExtension(opn.FileName)
'==========================================================
Mydb = opn.SafeFileName ' file name with extension
path = opn.FileName ' full path
TextBox2.ForeColor = Color.Black
TextBox2.BackColor = Color.Yellow
TextBox2.Text = path
If TextBox2.Text = "" Then
MsgBox("Error.............Please Select Any File", CType(MsgBoxStyle.Question + MsgBoxStyle.OkOnly, MsgBoxStyle))
TextBox2.Focus()
Return
End If
Label2.Hide()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub