Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Select File (dialog window)


Private Sub  SelectFile()
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = frmMain.hwnd
OpenFile.hInstance = App.hInstance
sFilter = "Image Files (*.jpg)" & Chr (0) & "*.jpg" & Chr (0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String (257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = App.path    '"C:\"
OpenFile.lpstrTitle = "Select Overlay Image File"
OpenFile.Flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
   'MsgBox "The User pressed the Cancel Button"
   'no change
Else
   'MsgBox "The user Chose " & Trim(OpenFile.lpstrFile)
  txtJPG.Text = OpenFile.lpstrFile
End If



End Sub