Need help converting from .NET to VB6
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:
Private Sub Version2()
Dim Cnt As Integer
Dim RegKey As RegistryKey = Registry.LocalMachine.CreateSubKey( _
"SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-2")
Dim SubKeys() As String = RegKey.GetSubKeyNames()
Dim DriverAdd As String
If SubKeys.Length > 0 Then
For Cnt = 0 To SubKeys.Length - 1
DriverAdd = (SubKeys(Cnt))
' Declares the True\False switch of whether or not the product header has
' been written in each of the variable files.
Dim dDriverName As Boolean
' Sets dDriverName to True
dDriverName = False
' Attempts to open the database, if not it returns an error
Try
' Declares myConnection as the database connection
myConnection = Me.cnDatabase()
' Opens the databse
myConnection.Open()
Catch ex As Exception
'Display Error Message
MessageBox.Show(ex.Message, "Database Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End
Application.Exit()
End Try
' Runs the data reader to gather all of the information from the DataSet (dsMain)
rdrVersion2 = Me.cmdGetValues.ExecuteReader()
' Performs the data read gainst the dataset from the database
With rdrVersion2
' Performs While statement while there are still records to be read
While .Read
' Reads data from the DataSet (dsMain) for the 5 columns in the DataSet
dataRow = Me.dsMain.tbl_PrintID_PrintName.NewRow
' Data: String name of the printer driver itself
dataRow(4) = .GetString(4)
' Checks to see if the driver string from the registry matches a driver in the database
If DriverAdd = dataRow(4) Then
' If dDriverName is True
If Not dDriverName Then
' Sets bHeader to True
dDriverName = True
' Write the driver name to the checked list box
lbDriversVer2.Items.Add(DriverAdd)
End If
End If
End While
End With
Try
' Close the database
myConnection.Close()
Catch ex As Exception
'Display Error Message
MessageBox.Show(ex.Message)
End Try
Next Cnt
End If
End Sub