Public Function OpenFile(ByVal TypeFile As String)
Dim _FileFull As String = ""
Dim _typefile As String = ""
If TypeFile = "pic" Then
_typefile = "Picture Files (*.JPG)|*.JPG;"
ElseIf TypeFile = "word" Then
_typefile = "Office Documents (*.doc)|*.doc; "
ElseIf TypeFile = "txt" Then
_typefile = "text Documents (*.txt)|*.txt; "
Else
_typefile = "PDF File (*.pdf)|*.pdf"
End If
Try
Dim dlg As OpenFileDialog = New OpenFileDialog()
dlg.Filter = _typefile
dlg.Title = "Open"
If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
_FileFull = dlg.FileName
'=============================================
If TypeFile = "pic" Then
Dim a As IO.FileInfo = New IO.FileInfo(_FileFull)
If a.Length > 20000 Then
Dim aaa = a.Length
MessageBox.Show("กรุณาเลือกไฟล์ขนาดไม่เกิน 200 KB")
OpenFile("pic")
End If
End If
'=============================================
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return _FileFull
End Function