Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7016569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:48:09+00:00 2026-05-27T22:48:09+00:00

I have a VB6 function, which executes an SQL delete. The function returns a

  • 0

I have a VB6 function, which executes an SQL delete. The function returns a boolean depending on whether or not the deletion was successful:

Public Function Delete(ByVal RecordID As Integer)  As Boolean

On Error GoTo ErrorGenerated //Execute SQL delete

Delete = True

Exit Function

ErrorGenerated: Delete = False

End Function

I read somewhere that it is better to return an integer, which dictates whether or not the deletion was successful. However, there can only be two outcomes from running the function from what I can see i.e. deleted or not deleted (not deleted if an error is thrown). Is it better to return an integer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:48:10+00:00Added an answer on May 27, 2026 at 10:48 pm

    I’d suggest your best bet is to return an enumerated type; each value for the enumeration can then explain to the caller what the problem is in a clear and unambiguous way, and new error reasons can be added later as required without breaking anything. Something like…

    Public Enum DB_ERRS
        Success
        NoConnection
        FailedForThisReason
        FailedForThatReason
        FailedForOtherReason
        Failed
    End Enum
    

    Then all your database access functions could return a value of this type…

    Public Function Delete(ByVal RecordID As Integer) As DB_ERRS
    
      On Error GoTo ErrorGenerated
      Execute SQL delete
      Delete = Success
      Exit Function
    
      ErrorGenerated:
    
      If Err.Number = this Then
         Delete = FailedForThisReason
      Else
         Delete = Failed
      End If
    
    End Function 
    

    Intellisense will even help you fill them in.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old VB6 app which I'm still trying to support. A few
I have a VB6 application (please don't laugh) which does a lot of drawing
I have a VB6 DLL, which I am referencing in VB.NET, I am calling
In my real application, I have a VB6 DLL which is called from classic
I have inherited some legacy vb6 code. It's a tool which generates a local
I have a VB6 app which is used by a large number of clients.
I have the following legacy VB6 function that I want to call from C#.
I have upgraded some VB6 code, which uses fixed length strings in custom types,
Please have a look at the following code, which I have run in VB6
I have a dialog in vb6 which changes the values being displayed in its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.