Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

The following code opens a folder browser. Everything works fine, except if the user presses the 'cancel' button. Is there any way to support this? The error I get is "Arithmetic operation resulted in an overflow". This is because I try to load a varible from an io stream. Here's the code:

 

      Public Function BrowseForFolder(ByVal sTitle As String) As String

       Const WINDOW_HANDLE As Long = 0
       Const NO_OPTIONS As Long = 0
       Const BIF_NEWDIALOGSTYLE As Long = 64

       Dim objShell As Object, objFolder As Object, objFolderItem As Object

       objShell = CreateObject("Shell.Application")
       objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, sTitle, NO_OPTIONS Or BIF_NEWDIALOGSTYLE, "My Computer")
       If Not objFolder Is Nothing Then
           objFolderItem = objFolder.Self
           BrowseForFolder = objFolderItem.Path
       End If

       objFolderItem = Nothing
       objFolder = Nothing
       objShell = Nothing

   End Function

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...