Question about Operating Systems

2 Answers

File handling in visual basic 6.0

Related to file handling give me complete details

Posted by on

2 Answers

  • Level 2:

    An expert who has achieved level 2 by getting 100 points


    An expert that got 5 achievements.


    An expert who has written 50 answers of more than 400 characters.


    An expert who has answered 200 questions.

  • Expert
  • 202 Answers
Re: file handling in visual basic 6.0

Following are a handful things u have to know about VB file handling

for more details...go to

File Handling (Generic)

While VB is working on a better approach (FileSystemObject), the built-in file handling statements are still the only way to access data other than through the VB database capabilities. Your skills in this area can make or break your ability to work with various formats. The OPEN/CLOSE statements are critical to success, but the LOF, EOF, and LEN functions are used even more often! It's also a given that you'll use the DIR function regularly.
Dir - Returns a filename that matches a pattern
temp$ = Dir ("*.*")
CurDir - Returns the current directory
temp$ = CurDir
MkDir - Creates a directory
mkdir ( "newdirectoryname" )
ChDir - Changes the current directory to a new location
chdir ( "newdirectoryname" )
ChDrive - Changes the current drive
ChDirve "A"
RmDir - Removes the indicated directory
rmdir ( "directoryname" )
Freefile - Returns an unused file handle
i = freefile
Open - Opens a file for access, locking it from other applications
open "filename" for input as #1
Close - Closes a file so that other applications may access it
close #1
LOF - Returns the length of a file in bytes
i = lof ( #1 )
EOF - Returns a boolean value to indicate if the end of a file has been reached
statusvariable = eof ( #1 )
Name As - Renames a file
name "filename1" as "filename2"
Kill - Deletes a file
kill "filename"
Fileattr - Returns attribute information about a file
i = int ( tempvariable )
GetAttr - Returns attributes of a file or directory
i = GetAttr("c:\windows\temp")
SetAttr - Sets the attributes of a file
SetAttr pathname, vbHidden
Reset - Closes all disk files opened by the OPEN statement
FileDateTime - Returns data file was created or last edited
FileDateTime ( filename )
FileLen - Returns length of file in bytes
FileLen ( filename )
FileCopy - Copies a file to a new name
FileCopy sourcefile, destinationfile
Lock - Controls access to a part or all of a file opened by OPEN
Lock #1
UnLock - Restores access to a part or all of a file opended by OPEN
UnLock #1
Width # - Set the output line width used by the OPEN statement
Width #2, 80
File Handling - ASCII-specific

While VB is working on a better approach (FileSystemObject), the built-in file handling statements are still the only way to access data outside of a data base. Your skills in this area can make or break your ability to work with various formats. The OPEN/CLOSE statements are critical to success, but the LOF, EOF, and LEN functions are necessary to build useful code.
Line Input - Reads an entire line of ASCII text
line input #1, tempvariable$
Write - Puts data in a file, with separators for the data
write #1, tempvariable$
Print - Puts data in a file with no separators
print #1, tempvariable$
Spc - Used in a print statement to move a number of spaces
Print #2, var1; spc(15); var2
Tab - Used in a print statement to move to TAB locations
Print #2, var1; Tab(20); var2
File Handling - Binary-specific

VB also support features which allow you to access a file on a byte-by-byte basis. The good thing about it is that you have more control, the bad thing is that you may have to write more code. Generally, a programmer will use the option (ASCII or Binary access) according to the least code he has to write. For binary access the Get/Put are equivalent to the Line Input and Print functions used in ASCII text file access. The big difference between the two is that binary access will read (Get) an exact number of bytes of data, and the reading can start at any byte within the file.
Get - Reads data from a file
get #1, anyvariable
Put - Puts data into a file
put #1, anyvariable
Seek - Moves the current pointer to a defined location in a file
seek #1, 26
input #1, anyvariable
Loc - Returns current position with an open file
i = Loc(#2)

Posted on Jan 24, 2008

  • Level 1:

    An expert who has achieved level 1.


    An expert that has over 10 points.


    An expert whose answer got voted for 2 times.

    Problem Solver:

    An expert who has answered 5 questions.

  • Contributor
  • 11 Answers
Re: file handling in visual basic 6.0

Not sure about the question.. mention ur need

Posted on Jan 24, 2008

Add Your Answer

0 characters

Uploading: 0%


Complete. Click "Add" to insert your video. Add


3 Points

Related Questions:

3 Answers

Is setup.exe.vbe safe to run?

probably not. .vbe means Visual Basic Encoded script. It seems as though someone tried to camouflage their script with a familiar filename (by prepending setup.exe in front of it. Is this on a CD or a file you received in email or downloaded?

Feb 04, 2014 | Microsoft Windows 7 Home Premium 64BIT...

1 Answer

System error &H80040111 (-2147221231)

Try installing your .NET frameworks and other Windows related runtimes.Also try re-installing the complete Microsoft Office package

Jan 28, 2012 | Microsoft Office Operating Systems

1 Answer

Can give an example of search command code?in visual basic 6.0

If you click on the following link you will find tutorial of Visual Basic and You will als so find example commands including some examples for parameter searches

hope it helpss rick

May 18, 2011 | Operating Systems

1 Answer

Need help in running a software made in visual basic 6

if that program has an executable file then install it or click the exe file to run the program. If it has no exe file then install a visaul basic 6.0 to open it and makeit run using F5 button.

Jun 09, 2009 | Operating Systems

1 Answer

I need help in Visual Basic as i am new to the visual basic 6

Dear, the following page contains the tutorial for beginner to visual basic 6, I hope that would be very helpful to you.

Best regards.

May 26, 2009 | Microsoft Windows XP Professional

1 Answer

How can i get the code of visual basic 6.0?

here the Hundreds of Visual Basic source code snippets and files. Copy and paste code from your browser directly into Visual Basic.

Jan 15, 2009 | Microsoft Windows XP Professional

1 Answer

Visual basic

What exactly do you want to do?

There are a lot of easy way is to control the mplayer app. This is a VBS script...

WshShell.Run "wmplayer.exe"
Setup a Scripting File System Object like "set oFSO=createobject("scripting.filesystemobject")"

Then use "WshShell.SendKeys" to send the keystrokes to the player

Another way is...

To embed the media then use Active X calls, which would requie visual basic.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Const DATA_FILE_EXTENSION As String = ".mp3"
Dim dlgFileDialog As New OpenFileDialog
With dlgFileDialog
.FilterIndex = 1
.RestoreDirectory = True
If .ShowDialog() = DialogResult.OK Then
'Play the sound file
Me.AxWindowsMediaPlayer1.URL = dlgFileDialog.FileName
End If
End With
End Sub

Sep 10, 2008 | Operating Systems

1 Answer


Sorry we can set one font style in one text box..

Mar 04, 2008 | Operating Systems

Not finding what you are looking for?
Operating Systems Logo

Related Topics:

3,163 people viewed this question

Ask a Question

Usually answered in minutes!

Top Operating Systems Experts


Level 3 Expert

18259 Answers

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Martin Murray

Level 3 Expert

1614 Answers

Are you an Operating System Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides