The two code examples below will show you how to format a floppy disk in VB. We will be using the Shell and SHFormatDrive functinos

It is possible to use DOS redirection commands to format your floppy. For instance, to format your diskdrive, print "Y"(no quotes) to a file name "myfile.txt". Then do this:

Shell "Format A: < myfile.txt"

====================================== Declare in a Module=================================
Declare Function SHFormatDrive Lib "shell32" (ByVal hWnd As Long, ByVal _
Drive As Long, ByVal fmtID As Long, ByVal options As Long) As Long
===========================================================================================

Private Sub cmdFormatFloppy_Click()
Dim DriveNumber As Integer
Dim RetVal

'Set DriveNumber to Format Floppy Disk:
'The last digit represents options: 
'0 = Full Window, User Selects Options
'1 = Full Window, Quick Format Selected automatically 
'2 = No Window, Quick Format performed automatically.

    DriveNumber = 0
    RetVal = SHFormatDrive(Me.hWnd, DriveNumber, 0&, 0&)
End Sub

Important Note: Make sure DriveNumber = 0.  Otherwise, you'll format
your hard drive!