Click here to Skip to main content
11,584,455 members (62,455 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
Posted 4-Feb-13 2:57am
Edited 4-Feb-13 3:09am
CHill60100.3K
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
saurabh kumar mahto at 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 at 4-Feb-13 10:03am
   
Is that error at compile time or run time?
saurabh kumar mahto at 4-Feb-13 10:12am
   
compile time error
Mike Meinz at 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?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 430
1 Sergey Alexandrovich Kryukov 369
2 Dave Kreskowiak 260
3 Richard Deeming 220
4 virusstorm 194
0 OriginalGriff 1,663
1 Sergey Alexandrovich Kryukov 1,229
2 Abhinav S 701
3 Dave Kreskowiak 667
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100