| View previous topic :: View next topic |
| Author |
Message |
alexltkv Regular
Joined: 08 Jul 2005 Posts: 61 Location: Iraq
|
Posted: Jul 11th, 2005 08:44 AM Post subject: open files? |
|
|
| I'm new at VB and I would like to know the code for opening files and documents. Stuff like MY MUSIC, MY PICTURES, ect... |
|
| Back to top |
|
RoofRabbit Regular

Joined: 06 Jul 2005 Posts: 95 Location: Lenoir, NC USA
|
Posted: Jul 11th, 2005 07:38 PM Post subject: Re: open files? |
|
|
| alexltkv wrote: | | Stuff like MY MUSIC, MY PICTURES, ect... |
Those are directories, not files. However, you can find basic file I/O in the vb section on my site as well as many other places on the net. _________________ Website - [link] |
|
| Back to top |
|
GreenEye Newbie
Joined: 20 Aug 2005 Posts: 1
|
Posted: Aug 20th, 2005 01:23 PM Post subject: |
|
|
Here is code to open a file and read it into TextBox. Place a text-box Text1 on the form and a cammand button Command1. Now cut paste this code :
| Code: | Private Sub Command1_Click()
Open "C:\autoexec.bat" For Input As #1
Text1.Text = Input(LOF(1), #1)
Close #1
End Sub |
This opens "C:\autoexec.bat" and displays its contents in TextBox.
Hope this is enough to get you started. |
|
| Back to top |
|
VB_Developer Newbie
Joined: 25 Feb 2006 Posts: 18 Location: Hyderabad, India
|
Posted: Feb 26th, 2006 09:08 AM Post subject: |
|
|
Hi,
You can also make use of the Microsoft Runtime Scripting library to play with files and folders.
| Quote: |
Go to Preferences in the Project menu, select the Microsoft Runtime Scripting.
go to ur code, create a File System Object
dim fs as fileSystemObject.
|
Hope this will help you in togling with files and folders.
Thanks |
|
| Back to top |
|
saheb_vb Newbie
Joined: 10 May 2006 Posts: 2
|
Posted: Jun 6th, 2006 01:13 AM Post subject: |
|
|
The code :
Private Sub Command1_Click()
Open "C:\autoexec.bat" For Input As #1
Text1.Text = Input(LOF(1), #1)
Close #1
End Sub
does not work.. |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Jun 6th, 2006 06:32 AM Post subject: |
|
|
| saheb_vb wrote: | The code :
Private Sub Command1_Click()
Open "C:\autoexec.bat" For Input As #1
Text1.Text = Input(LOF(1), #1)
Close #1
End Sub
does not work.. |
What happens? Nothing? Does an error occur? _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
|