Results 1 to 5 of 5

Thread: VB 2008 code vs VB 6

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    15

    VB 2008 code vs VB 6

    I am trying to rewrite my VB 6 code to VB 2008. Can you provide me some direction how to best rewrite the VB 6 code below to VB 2008. This code was adapted from "Beginning VB6 Databases" by John Connell. I created a desktop application and now I'm trying to rewrite it to make it a client server app.

    Specifically, I'm trying to find Methods in VB 2008 that are functionally the same as the dbEditNone, dbEditInProgress, etc.

    vb Code:
    1. Public Sub updateButtons(Optional bLockEm As Variant)
    2.  
    3. '-----------------------------------------------------
    4. '-The position of the 0 or 1 in the string represents
    5. '-a specific button in our cmdButton control array.
    6. '-----------------------------------------------------
    7. '-Position      Button
    8. '-  0           move first
    9. '-  1           move previous
    10. '-  2           move next
    11. '-  3           move last
    12. '-  4           add a new record
    13. '-  5           edit the current record
    14. '-  6           save the current record
    15. '-  7           delete the current record
    16. '-  8           undo any current changes
    17. '-  9           find a specific record
    18. '-  10          scan a file
    19. '-  11          open a saved file
    20. '-  12          done. Unload the form
    21. '-----------------------------------------------------
    22.  
    23. Select Case Data1.Recordset.EditMode
    24.  
    25. Case dbEditNone     '-no editing taking place, just handle navigation
    26.     If (lTotalRecords >= 2) Then
    27.         If (Data1.Recordset.BOF) Or (Data1.Recordset.AbsolutePosition = 0) Then
    28.             navigateButtons ("0011110101011")
    29.         ElseIf (Data1.Recordset.EOF) Or (Data1.Recordset.AbsolutePosition = lTotalRecords - 1) Then
    30.             navigateButtons ("1100110101011")
    31.         Else
    32.             navigateButtons ("1111110101011")
    33.         End If
    34.     ElseIf (lTotalRecords > 0) Then
    35.         navigateButtons ("0000110100111")
    36.     Else
    37.         navigateButtons ("0000100000001")
    38.     End If
    39.     If (Not IsMissing(bLockEm)) Then
    40.         lockTheControls (bLockEm)
    41.     End If
    42. Case dbEditInProgress       '-we are editing a current record
    43.     Call lockTheControls(False)
    44.     navigateButtons ("0000001010100")
    45.     If (Text1(0).Visible) Then Text1(0).SetFocus
    46. Case dbEditAdd              '-we are adding a new record
    47.     Call lockTheControls(False)
    48.     navigateButtons ("0000001010100")
    49.     If (Text1(0).Visible) Then Text1(0).SetFocus
    50. End Select
    51.  
    52. End Sub
    53.  
    54. Public Sub navigateButtons(sButtonString As String)
    55.  
    56. '--------------------------------------------------
    57. '-This routine handles setting the enabled
    58. '-property to true/false on the buttons
    59. '--------------------------------------------------
    60. '-A string of 0101 passed.  If 0, disabled
    61. '--------------------------------------------------
    62.  
    63. Dim iIndx As Integer
    64. Dim iButtonLength As Integer
    65.  
    66. sButtonString = Trim$(sButtonString)
    67. iButtonLength = Len(sButtonString)
    68.  
    69. For iIndx = 1 To iButtonLength
    70.     If (Mid$(sButtonString, iIndx, 1) = "1") Then
    71.         Command1(iIndx - 1).Enabled = True
    72.     Else
    73.         Command1(iIndx - 1).Enabled = False
    74.     End If
    75. Next
    76.  
    77. DoEvents
    78.  
    79. End Sub
    Last edited by Hack; Mar 5th, 2010 at 07:46 AM. Reason: Added Highlight Tags

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: VB 2008 code vs VB 6



    That code is DAO, which is actually for versions of VB earlier than VB6 - it was replaced in/before 1998, and the VB6 help for DAO explicitly says not to use it.

    There are also several things about that code that are far less than ideal (such as coding around a bound control, rather than fully using code), so I would recommend completely forgetting about it, and starting again.


    As you are using VB.Net, you should be using ADO.Net, and you can find good tutorials etc about it in the VB.Net section of our Database Development FAQs/Tutorials (at the top of the Database Development forum)

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    15

    Re: VB 2008 code vs VB 6

    Thank you for your response. I am using ADO.Net. What I am trying to do is to "disable", gray-out some of the navigation buttons I created when the program is in certain states. For example, when the user selects the "Add New" button on the form, I want to "disable" the Edit, Delete, Search and Open control buttons on the form and enable the Save and Undo buttons. I am trying to provide the user a "bullet proof" interface. In my original program this was accomplished by checking the "Edit Mode" of the Recordset. I'm trying to figure out how to accomplish this with ADO.Net. Thanks again!

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: VB 2008 code vs VB 6

    There are a variety of methods within ADO.Net, and we can't really help unless we know some details of what you are actually doing already.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VB 2008 code vs VB 6

    The short answer to your question is you would need to look at the .RowState property of the row in question.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width