VB6 转换为 VB.net 变体问题
我的任务是将 VB6 程序转换为 VB.NET。在我的在线研究中,每个人似乎都说我需要检查我的代码并摆脱我拥有的任何变体。到目前为止,我的运气很好,但在更换这个时遇到了问题。
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
我对 VB(无论是 6 还是 .net)还是很陌生,而且我很难找到替代方案。 VB.net 中的转换工具可以很好地处理这个问题吗?或者我需要改变这个吗?如果我这样做,有更好的选择吗?原谅我的菜鸟。
先感谢您。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看代码,您可能会将 VB6 Listview 控件替换为 .NET
ListView 控件
。您列出的Sub
看起来像是处理 ListView 控件的 DragDrop 事件(我对该控件不熟悉,但这就是它的用途,从名称来看) 。看一下
DragDrop
事件和 ListView 控件的DoDragDrop()
方法,了解如何使用字符串集合作为与事件关联的数据。Looking at the code, it's likely that you'll be replacing the VB6 Listview control with the .NET
ListView control
. TheSub
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 theDoDragDrop()
method of the ListView control, to see how you can use a collection of strings as the data associated with the event.提前进行所有可能的更改会很有帮助,但如果出现问题,您可能会节省一些时间等待转换后。
之后您将需要进行一些更改,但您可以继续进行 .net 转换,然后清理留下的内容。
例如,您可能在 .net 转换之前将此处的变体转换为字符串,却发现 .net 列表视图 DragEventArgs.data 有所不同。 (我不确定它是什么,但转换后会更容易找到。)
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.)