|
-
Oct 19th, 2000, 04:32 PM
#1
Thread Starter
Junior Member
I can currently pick up Multiplefiles but if I try to only select one file it throws up the MsgBox "Please Select File(s) to be Uploaded."--which it should send if they did not select a file. How can I allow someone to pick up a single file as well? Here is the code
Private Sub Command1_Click()
Dim iCounter As Integer
Dim sFolder As String
With CommonDialog1
List1.Clear
.FileName = ""
.InitDir = Trim(UploadFile)
.Flags = cdlOFNExplorer Or cdlOFNAllowMultiselect Or cdlOFNHideReadOnly
.Filter = "All files (*.*)|*.*|Text files (*.txt)|*.txt|"
.ShowOpen
On Error GoTo ErrorHandler
iCounter = 1
sFolder = Mid(.FileName, 1, InStr(iCounter, .FileName, vbNullChar) - 1)
Do Until InStr(iCounter + 1, .FileName, vbNullChar) = 0
iCounter = InStr(iCounter + 1, .FileName, vbNullChar) + 1
If InStr(iCounter, .FileName, vbNullChar) = 0 Then
List1.AddItem Mid(.FileName, iCounter)
Else
List1.AddItem Mid(.FileName, iCounter, InStr(iCounter + 1, .FileName, vbNullChar) - iCounter)
End If
Loop
If iCounter > 1 Then
Label1.Caption = "Here are the file(s) you have selected to upload, if this is not correct please choose the correct file(s)"
Label1.Visible = True
List1.Visible = True
Else
End If
End With
iCounter = 0
Exit Sub
ErrorHandler: ''Error Handeling Routine if the file is not found.
Select Case Err.Number
Case 5
Label1.Visible = False
List1.Visible = False
MsgBox "Please Select File(s) to be Uploaded."
Err.Clear
Case Else
'MsgBox Err.Number, Err.HelpFile, Err.HelpContext
MsgBox Err.Description
Resume Next
End
End Select
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|