如何将以下vb6属性更改为vb.net。 [英] How to change the below vb6 property into vb.net.

查看:87
本文介绍了如何将以下vb6属性更改为vb.net。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将下面的vb6属性更改为vb.net?

注意,这里让2个参数作为参数





 私有 lAttribute  As  MyAutomation.AttributeMap 

公开 属性 值(pName As 字符串,pValue As 变体
lAttribute.Add pName,pValue
结束 属性

公开 属性 < span class =code-keyword>获取值(pName 作为 字符串
Value = lAttribute.Item(pName)
结束 物业





谢谢

解决方案

当您尝试在VB.NET中向Set方法添加第二个参数时,它会报告

Quote:

''Set''方法不能有多个参数。



你最好有一个设置这个的函数,例如

 < span class =code-keyword>公共  Sub  SetValue( ByVal  pName  as  字符串 ByVal  pValue  As   Variant 
lAttribute.Add pName,pValue
End Sub





将VB6属性转换为.net是键入

Quote:

公共属性

然后点击tab键 - 然后填写指示的字段。


< blockquote>属性只接受一个参数。



如果要传递多个参数,请传递包含所有值的单个结构,或使用 Public Sub 公共函数



下面是我转换的一个DLL的属性的实际代码从VB6到VB .NET:



VB6

 Dim strTargetFilename as String =
公共属性获取TargetFile()As Variant
TargetFile = strTargetFilename
结束物业

公共物业让TargetFile(ByVal vNewValue作为变体)
strTargetFilename = vNewValue
结束物业





VB .NET

 Dim strTargetFilename as String =
Public Property TargetFile()As String
Get
TargetFile = strTargetFilename
End Get
Set(value As String)
strTargetFilename = value
End Set
End Property


How to change the below vb6 property into vb.net ?
note,here Let have 2 arguments as parameter


Private lAttribute As MyAutomation.AttributeMap

Public Property Let Value(pName As String, pValue As Variant)
    lAttribute.Add pName, pValue
End Property

Public Property Get Value(pName As String)
    Value = lAttribute.Item(pName)
End Property



Thanks

解决方案

When you try to add a second parameter to a Set method in VB.NET it reports

Quote:

''Set'' method cannot have more than one parameter.


You would be better off having a function that sets this e.g.

Public Sub SetValue(ByVal pName as String, ByVal pValue As Variant)
    lAttribute.Add pName, pValue
End Sub



A general hint for converting VB6 properties into .net is to type

Quote:

Public Property

and then hit the tab key - then fill in the indicated fields.


Properties only accept one parameter.

If you want to pass multiple parameters, pass a single Structure containing all of the values or declare a Method using Public Sub or Public Function

Below is actual code for a property from one of my DLLs that I converted from VB6 to VB .NET:

VB6

Dim strTargetFilename as String=""
Public Property Get TargetFile() As Variant
    TargetFile = strTargetFilename
End Property

Public Property Let TargetFile(ByVal vNewValue As Variant)
    strTargetFilename = vNewValue
End Property



VB .NET

Dim strTargetFilename as String=""
Public Property TargetFile() As String
    Get
        TargetFile = strTargetFilename
    End Get
    Set(value As String)
        strTargetFilename = value
    End Set
End Property


这篇关于如何将以下vb6属性更改为vb.net。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆