Results 1 to 5 of 5

Thread: VB 2008 code vs VB 6

Threaded View

  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

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