I posted this in the VB6 forums but have not gotten any replies in a week or so so I figured I would through this to you guys as you were so helpful in writting the initial app.

OK, I know this is kind of backwards but I have written a utility that works really great in VB.NET and i need to re-write it in VB6 with aboslutely no VB6 experience. Below is a snippit of code that I have written in VB.NET for my program and I need to convert it to VB6. There is actually another one that in much more complicated but this will get me started, I hope. The other one involves connectivity to a database but I can worry about that later. I know my syntax and form is not perfect, please keep in mind before bashing that I have never coded before the app that I wrote in .NET. Can anyone help me or know of a program that can help? Any assistance would is greatly appreciated.

Thanks,

Jim


VB Code:
  1. Private Sub Version2()
  2.  
  3.         Dim Cnt As Integer
  4.         Dim RegKey As RegistryKey = Registry.LocalMachine.CreateSubKey( _
  5.            "SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-2")
  6.         Dim SubKeys() As String = RegKey.GetSubKeyNames()
  7.         Dim DriverAdd As String
  8.         If SubKeys.Length > 0 Then
  9.             For Cnt = 0 To SubKeys.Length - 1
  10.                 DriverAdd = (SubKeys(Cnt))
  11.  
  12.                 ' Declares the True\False switch of whether or not the product header has
  13.                 ' been written in each of the variable files.
  14.                 Dim dDriverName As Boolean
  15.  
  16.                 ' Sets dDriverName to True
  17.                 dDriverName = False
  18.  
  19.                 ' Attempts to open the database, if not it returns an error
  20.                 Try
  21.                     ' Declares myConnection as the database connection
  22.                     myConnection = Me.cnDatabase()
  23.                     ' Opens the databse
  24.                     myConnection.Open()
  25.  
  26.                 Catch ex As Exception
  27.                     'Display Error Message
  28.                     MessageBox.Show(ex.Message, "Database Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
  29.                     End
  30.                     Application.Exit()
  31.                 End Try
  32.  
  33.                 ' Runs the data reader to gather all of the information from the DataSet (dsMain)
  34.                 rdrVersion2 = Me.cmdGetValues.ExecuteReader()
  35.  
  36.                 ' Performs the data read gainst the dataset from the database
  37.                 With rdrVersion2
  38.  
  39.                     ' Performs While statement while there are still records to be read
  40.                     While .Read
  41.  
  42.  
  43.                         ' Reads data from the DataSet (dsMain) for the 5 columns in the DataSet
  44.                         dataRow = Me.dsMain.tbl_PrintID_PrintName.NewRow
  45.  
  46.                         ' Data: String name of the printer driver itself
  47.                         dataRow(4) = .GetString(4)
  48.  
  49.                         ' Checks to see if the driver string from the registry matches a driver in the database
  50.                         If DriverAdd = dataRow(4) Then
  51.  
  52.                             ' If dDriverName is True
  53.                             If Not dDriverName Then
  54.                                 ' Sets bHeader to True
  55.                                 dDriverName = True
  56.                                 ' Write the driver name to the checked list box
  57.                                 lbDriversVer2.Items.Add(DriverAdd)
  58.                             End If
  59.  
  60.                         End If
  61.  
  62.                     End While
  63.  
  64.                 End With
  65.  
  66.                 Try
  67.                     ' Close the database
  68.                     myConnection.Close()
  69.                 Catch ex As Exception
  70.                     'Display Error Message
  71.                     MessageBox.Show(ex.Message)
  72.                 End Try
  73.  
  74.             Next Cnt
  75.  
  76.         End If
  77.  
  78.     End Sub