Solved

vb.net structure default property

Posted on 2009-07-01
6
781 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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 27

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

813 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now