views:

526

answers:

2

I have been tasked to convert out VB6 program to VB.NET. In my research online everyone seems to say I need to go through my code and get rid of any Variants I have. I have had pretty good luck so far, but I am having an issue in replacing this one.

Private Sub lvThumbView_OLEDragDrop(Data As MSComctlLib.DataObject)
    Dim File As Variant

    For Each File In Data.Files
        Select Case UCase(right(File, 3))
            Case "JPG", "BMP"
            ..... 
        End Select
    Next File
End Sub

I am still pretty new to VB (either 6 or .net) and I am having a hard time finding an alternative for this. Will the convert tool in VB.net handle this just fine? Or do I need to change this? If I do, is there a better alternative for this? Forgive my noobness.

Thank you in advance.

+1  A: 

Looking at the code, it's likely that you'll be replacing the VB6 Listview control with the .NET ListView control. The Sub that you've listed looks like it handles the DragDrop event of the ListView control (I'm not familiar with the control, but this is what it appears to be for, going by the name).

Take a look at the DragDrop event and the DoDragDrop() method of the ListView control, to see how you can use a collection of strings as the data associated with the event.

Russ Cam
Ya I figured the VB control I am using now is going to get replaced. I guess I got hung up on trying to replace Variant; I didn't see the bigger picture. There are definitely some other issues in this code that need resolving first, but I think that this is a good answer. Thank you
Ian Kremer
A: 

It will be helpful to make all the changes you can beforehand, but if there is a question, you might save some time to waiting until after the conversion.

You will have a few changes to make afterward, but you can go ahead and make the .net conversion,then clean up what is left behind.

For example, you might convert the variant here to a string before the .net conversion, only to find out the the .net listview DragEventArgs.data is something different. (I'm not sure what it is, but it would be easier to find out after you did the conversion.)

xpda