Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

vb.net structure default property

Posted on 2009-07-01
6
784 Views
Last Modified: 2012-05-07
I am trying to use the vb.net upgrade wizard in vs5 to upgrade an old application.
But the IDE shows some errors that I don't now how to fix.

To explain further: I have a type that the wizard has converted into a structure, I have an array of that type, but I pass just the value of the array that I want to work on at that moment.
See my example:



 


Normal      UPGRADE_WARNING: Couldn't resolve default property of object tmpClient. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'      C:\Clients\Net\....\clsClientSort.vb      84

Public Structure typCliSelect
   Dim ID As String
   Dim ClientName As String
End Structure
 
Dim Aray() as typCliSelect
Redim aray(10) as typClient
 
for I = 1 to 10
  ProcessClient(Aray(i))
next
 
public function ProcessClient(MyClient as typCliSelect) as long
' Do some stuff ...
end function

Open in new window

0
Comment
Question by:sidwelle
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:prashantagarw10
ID: 24756295
You have two options but u will need to explore a bit on each of these to see which one suits you better

1. Define an indexer on class. this will behave like a default property. Search on google for dotnet class indexer and you shd. see some relevant info.

2. Define a class's default property just above the class declaration like :
<DefaultProperty("MyProperty")> _
Public Class typCliSelect
    ...
    Public Property MyProperty() As String
        ...
    End Property
    ...
End Class

Do not use the default keyword within property itself.

this should solve your problem.

Cheers!
Prashant
0
 

Author Comment

by:sidwelle
ID: 24756519
Not sure, I don't really care about the default property.
I want to pass 1 component of the array, not one property of the structure/type.
I want to pass the whole structure.
0
 

Author Comment

by:sidwelle
ID: 24772272
From what I have read, the correct way to assign one user defined structure to another is exactly as I di
it:
Dim A as MyStruct
Dim B as MyStruct
A = B
Its just the conversion wizard that throws an error, right ?

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 5

Accepted Solution

by:
prashantagarw10 earned 400 total points
ID: 24773685
yes your code is right and thats y i was wondering what your question actually is.
i thought you were asking a work around for the error thrown by conversion wizard so what i had told was a resolution to that. otherwise your code looks fine. Even though you might need to defien a default property if you have used it some where in your code so there my answer will help you.

Cheers!
Prashant
0
 
LVL 28

Assisted Solution

by:Ark
Ark earned 100 total points
ID: 24811199
1. Not sure, but VB.net default declaration is ByVal while vb6 is ByRef.
Probably
public function ProcessClient(ByRef MyClient as typCliSelect) as long 'integer?
do the trick?
2. Try use Classes instead of structures with explicit 'New' keyword
Public Class typCliSelect
   Dim ID As String
   Dim ClientName As String
'Public Sub New()
'Initialize some properties
'End Sub
End Class
Dim Aray() as typCliSelect
Redim aray(10) as typClient
 
for I = 1 to 10
  Aray(i)=New typClient
  ProcessClient(Aray(i))
next
0
 

Author Closing Comment

by:sidwelle
ID: 31598826
thanks for the help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Checking a checkbox based on SQL DataReader boolean value in ASP.NET(VB) 2 32
Visual Studios 1 76
JSON Deserialize issue 6 26
Collapse and expand table in Word 2010 2 32
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question