I need some help for creating a button that can allow the users to browse to a location and upload a file. I am new to VB, and any help would be greatly appreciated.
creating a browse button with VB6
Collapse
X
-
Tags: None
-
Originally posted by NasirMunirI need some help for creating a button that can allow the users to browse to a location and upload a file. I am new to VB, and any help would be greatly appreciated.
Do you have anything working thus far?
Dököll -
Try use Microsoft CommonDialog control for the purpose . Use the search box on the top right side of your page for further details.Comment
-
This is what I would use.
Code:Private Sub cmdLoad_Click() If lstLoad.ListCount > 1 Then lstLoad.Clear On Error GoTo Cancelled cdlcommon.DialogTitle = "Load List" cdlcommon.CancelError = True cdlcommon.InitDir = App.Path cdlcommon.Flags = &H4 cdlcommon.Filter = "Text File (*.txt)|*.txt|All files (*.*)|*.*" cdlcommon.ShowOpen Cancelled: End Sub
Then to take the file you loaded you would use cdlcommon.filen ame
Example: I would use a function to add it to a list.
Call LoadFile(cdlcom mon.FileName)
Code:Private Function LoadFile(strFile As String) On Error Resume Next Dim opt As Integer, tmpStr As String opt = FreeFile Open strFile For Input As #opt While Not EOF(opt) Input #opt, tmpStr lstLoad.AddItem tmpStr Wend Close #opt End Function
Comment
-
Originally posted by NasirMunirI need some help for creating a button that can allow the users to browse to a location and upload a file. I am new to VB, and any help would be greatly appreciated.
Add Microsoft common control to your form.
and add this code to your browse buttons code.
Code:commondialog1.showopen commondialog1.filter="*.txt|Text Files|*.*|All Files" ' You can add or change this filter. msgbox "You have choose"&commondialog1.filename
Now your browse button is ready to work.
GOOD LUCK
ALIComment
-
Thanks to all.
After banging my head for few days, I figured it out how to do that :). I was not aware of command dialog box. At any rate, thanks again for all the help.
Originally posted by Ali RizwanHere is a simple way for browse button...
Add Microsoft common control to your form.
and add this code to your browse buttons code.
Code:commondialog1.showopen commondialog1.filter="*.txt|Text Files|*.*|All Files" ' You can add or change this filter. msgbox "You have choose"&commondialog1.filename
Now your browse button is ready to work.
GOOD LUCK
ALIComment
Comment