Generating Run Time Errors in visual basic .This is a simple application to show you that how can u generate different runtime errors.
API Declarations
and 2 buttons 1 for cancel and other for generate
there are 73 runtime errors i have put . It is useful in applications
Private Sub Form_Load()
List1.AddItem "Printer error:"
List1.AddItem "Function incorrect:"
List1.AddItem "System cannot find the device specified:"
List1.AddItem "Media is write protected:"
List1.AddItem "System cannot find the file specified:"
List1.AddItem "System cannot find the path specified:"
List1.AddItem "The data is invalid:"
List1.AddItem "The system cannot find the drive specified"
List1.AddItem "The directory cannot be removed:"
List1.AddItem "The device is not ready:"
List1.AddItem "Printer is out of paper:"
List1.AddItem "System cannot write to the specified device:"
List1.AddItem "System cannot read from the specified device:"
List1.AddItem "Device attached to the system is not functioning:"
List1.AddItem "Network path was not found:"
List1.AddItem "Network is busy:"
List1.AddItem "The specified network name is no longer available:"
List1.AddItem "Network access is denied:"
List1.AddItem "Network access is denied"
List1.AddItem "Network resource cannot be found:"
List1.AddItem "Network name cannot be found:"
List1.AddItem "File exsists:"
List1.AddItem "File or directory not be created:"
List1.AddItem "Storage to process this request is not available:"
List1.AddItem "Local device name is already in use:"
List1.AddItem "Specified network password is not correct:"
List1.AddItem "Parameter is incorrect:"
List1.AddItem "The disk is in use or locked by another process:"
List1.AddItem "The system cannot open the device or file specified:"
List1.AddItem "The file name is too long:"
List1.AddItem "There is not enough space on the disk:"
List1.AddItem "No more internal file identifiers available:"
List1.AddItem "The system does not support the command requested:"
List1.AddItem "This function is only valid in Win32 mode :"
List1.AddItem "The filename, directory name, or volume label syntax is incorrect:"
List1.AddItem "The system call level is not correct:"
List1.AddItem "The disk has no volume label:"
List1.AddItem "The specified module could not be found:"
List1.AddItem "The specified procedure could not be found:"
List1.AddItem "The file pointer cannot be set on the specified device or file:"
List1.AddItem "The directory is not a subdirectory of the root directory:"
List1.AddItem "The directory is not empty:"
List1.AddItem "Not enough resources are available to process this command:"
List1.AddItem "The path specified cannot be used at this time:"
List1.AddItem "System trace information was not specified in your CONFIG.SYS:"
List1.AddItem "Cannot create another thread:"
List1.AddItem "The recipient process has refused the signal:"
List1.AddItem "The specified path is invalid:"
List1.AddItem "No more threads can be created in the system:"
List1.AddItem "The requested resource is in use:"
List1.AddItem "Cannot create a file when that file already exists:"
List1.AddItem "%1 is not a valid Win32 application:"
List1.AddItem "The operating system cannot run this application program:"
List1.AddItem "The code segment cannot be greater than or equal to 64KB:"
List1.AddItem "The filename or extension is too long:"
List1.AddItem "No more data is available:"
List1.AddItem "The Copy API cannot be used:"
List1.AddItem "The directory name is invalid:"
List1.AddItem "Invalid access to memory location:"
List1.AddItem "Recursion too deep, stack overflowed:"
List1.AddItem "Cannot complete this function:"
List1.AddItem "Invalid flags:"
List1.AddItem "The configuration registry key is invalid:"
List1.AddItem "The database specified does not exist:"
List1.AddItem "Media in drive may have changed:"
List1.AddItem "Unable to unload the media:"
List1.AddItem "No media in drive:"
List1.AddItem "A dynamic link library (DLL) initialization routine failed:"
List1.AddItem "A system shutdown is in progress:"
List1.AddItem "The specified device name is invalid:"
List1.AddItem "The specified network provider name is invalid:"
List1.AddItem "The format of the specified computer name is invalid:"
List1.AddItem "he format of the specified domain name is invalid:"
List1.AddItem "The format of the specified service name is invalid:"
List1.AddItem "The format of the specified network name is invalid:"
List1.AddItem "The format of the specified share name is invalid:"
List1.AddItem "The format of the specified password is invalid:"
List1.AddItem "The format of the specified message name is invalid:"
End Sub
On the button name generated put this code
Private Sub cmdgenerate_Click()
Dim i As Integer
For i = 0 To List1.ListCount
If List1.ListIndex = 0 Then
checkerror = False
Err.Raise 62, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 1 Then
Err.Raise 1, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 2 Then
Err.Raise 5, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 3 Then
Err.Raise 20, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 4 Then
Err.Raise 19, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 5 Then
Err.Raise 2, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 6 Then
Err.Raise 3, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 7 Then
Err.Raise 13, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 8 Then
Err.Raise 15, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 9 Then
Err.Raise 16, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 10 Then
Err.Raise 21, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 11 Then
Err.Raise 28, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 12 Then
Err.Raise 29, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 13 Then
Err.Raise 30, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 14 Then
Err.Raise 31, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 15 Then
checkerror = False
Err.Raise 53, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 16 Then
Err.Raise 54, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 17 Then
Err.Raise 64, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 18 Then
Err.Raise 65, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 19 Then
Err.Raise 66, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 20 Then
Err.Raise 67, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 21 Then
Err.Raise 80, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 22 Then
Err.Raise 82, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 23 Then
Err.Raise 84, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 24 Then
Err.Raise 85, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 25 Then
Err.Raise 86, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 26 Then
Err.Raise 87, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 27 Then
Err.Raise 108, Err.Source, Err.Description, Err.HelpFile
checkerror = False
ElseIf List1.ListIndex = 28 Then
Err.Raise 110, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 30 Then
Err.Raise 111, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 31 Then
Err.Raise 112, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 31 Then
Err.Raise 113, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 32 Then
Err.Raise 119, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 33 Then
Err.Raise 120, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 34 Then
Err.Raise 123, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 35 Then
Err.Raise 124, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 36 Then
Err.Raise 125, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 37 Then
Err.Raise 126, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 38 Then
Err.Raise 127, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 39 Then
Err.Raise 132, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 40 Then
Err.Raise 144, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 41 Then
Err.Raise 145, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 42 Then
Err.Raise 147, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 43 Then
Err.Raise 148, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 44 Then
Err.Raise 149, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 45 Then
Err.Raise 150, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 46 Then
Err.Raise 155, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 47 Then
Err.Raise 156, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 48 Then
Err.Raise 161, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 49 Then
Err.Raise 164, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 50 Then
Err.Raise 170, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 51 Then
Err.Raise 183, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 52 Then
Err.Raise 193, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 53 Then
Err.Raise 196, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 54 Then
Err.Raise 200, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 55 Then
Err.Raise 206, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 56 Then
Err.Raise 259, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 57 Then
Err.Raise 266, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 58 Then
Err.Raise 267, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 59 Then
Err.Raise 998, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 60 Then
Err.Raise 1001, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 61 Then
Err.Raise 1003, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 62 Then
Err.Raise 1004, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 63 Then
Err.Raise 1010, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 64 Then
Err.Raise 1065, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 65 Then
Err.Raise 1110, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 66 Then
Err.Raise 1109, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 67 Then
Err.Raise 1112, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 68 Then
Err.Raise 1114, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 69 Then
Err.Raise 1115, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 70 Then
Err.Raise 1200, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 71 Then
Err.Raise 1204, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 72 Then
Err.Raise 1210, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 73 Then
Err.Raise 1212, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 74 Then
Err.Raise 1213, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 75 Then
Err.Raise 1214, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 76 Then
Err.Raise 1215, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 77 Then
Err.Raise 1216, Err.Source, Err.Description, Err.HelpFile
ElseIf List1.ListIndex = 78 Then
Err.Raise 1217, Err.Source, Err.Description, Err.HelpFile
End If
Next i
End Sub
on the button name cancel write this code
Private Sub Command2_Click()
End
End Sub
Thats it now run the program and you can see runtime errors complied by visual basic