English 中文(简体)
VB6 convert to VB.net Variant question
原标题:

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.

最佳回答

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.

问题回答

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.)





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签