Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to change the below vb6 property into vb.net ?
note,here Let have 2 arguments as parameter


VB
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
Posted
Updated 4-Feb-13 3:09am
v3

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
 
Share this answer
 
v2
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.
VB
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.
 
Share this answer
 
Comments
saurabh kumar mahto 4-Feb-13 9:57am    
Here I tried doing this,

Private lAttribute As MyAutomation.AttributeMap

Public Function Value(ByVal pName As String, ByVal pValue As Object) As String
lAttribute.Add(pName, pValue)
Return pValue
End Function

i am getting this error prompt as below,
Argument not specified for parameter'pValue'of Public Sub Value(pName As String,pValue as Object)
in ModuleDBParam.vb
vDBSection.Value("SI::ESTEC::CommonSetup::Release") = "12A"
CHill60 4-Feb-13 10:03am    
Is that error at compile time or run time?
saurabh kumar mahto 4-Feb-13 10:12am    
compile time error
Mike Meinz 4-Feb-13 10:12am    
In the call to the vDBSection.value function above, you are passing one parameter to the method but you have the method declared with two parameters.

Also, why would you have vDBSection.value return pValue, when it was one of the values passed into the function?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900