structures in VB.Net

  • Thread starter Thread starter sid
  • Start date Start date
S

sid

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.

The wizard though an error:
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

but I am not concerned with the default property, I just want to pass
the element of the Array. In VS I get the previous error at the first
line of the function. This is what use to work well in VB6.

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


How do I pass just one element of the array ?
Thanks
 
sid said:
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.

The wizard though an error:
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

but I am not concerned with the default property, I just want to pass
the element of the Array. In VS I get the previous error at the first
line of the function. This is what use to work well in VB6.

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


How do I pass just one element of the array ?
Thanks

First thing is to turn on Strict on. This will give you better info on your
code and in the long run "force" you to write better code before testing.

Second is the Redim statement. It does not use the "as typClient". This
should show as a compile error.

Next since you are using an array it's elements are from 0 to 9 in your
example. Your code from 1 to 10 will not work.

If you are using VS 2005 and up you should change this to use Generics.
This will give you better checking while typing and in the long run will
execute quicker.

Hope this helps
LS
 
First thing is to turn on Strict on.  This will give you better info onyour
code and in the long run "force" you to write better code before testing.

Second is the Redim statement.  It does not use the "as typClient".  This
should show as a compile error.

Next since you are using an array it's elements are from 0 to 9 in your
example.  Your code from 1 to 10 will not work.

If you are using VS 2005 and up you should change this to use Generics.
This will give you better checking while typing and in the long run will
execute quicker.

Hope this helps
LS- Hide quoted text -

- Show quoted text -

Thank you for the imput, but that dose not help me solve my problem.
What I want to know is how to pass 1 element of an array to a
function.
Thanks
 
Thank you for the imput, but that dose not help me solve my problem.
What I want to know is how to pass 1 element of an array to a
function.
Thanks

You simply do what you always did:

Dim ar(9) As Integer
S(ar(0))

Public Sub S(ByVal i As Integer)
....
End Sub
 
I can't see from your sample what tmpClient is, but it may be that the error
is occurring at the first line of code in the function - the line you have
provided as 'Do some stuff'. The error message usually indicates that you
have referred to a structure when you intended to refer to an element of the
structure.

Your code appears OK for passing the i'th element of the array to the
function. The errror may be the result of confusion in the conversion
process following the attempt to redim the array as a different type.
 
Lloyd,

An array in VB is 0 to 9 and 1 to 10 as it is declared as x(10), this is
simply because in VB an array holds one item more because of backwards
compatibility

Cor
 
Sid,

I did not know that it was possible in VB6 to create a new array with Redim,
but that is what you actually try to do
Dim Aray() as typCliSelect
Redim aray(10) as typClient
It are two different types

Cor
 
Huh ?

Isn`t VB just zero indexed ? wich would mean that X(10) would hold eleven
elements
0, 1 ,2,3,4,5,6,7,8,9,10= 11

Michel
 
Huh ?


Isn`t VB just zero indexed ? wich would mean that X(10) would hold eleven
elements
0, 1 ,2,3,4,5,6,7,8,9,10= 11

Michel

VB.NET is just zero indexed. VB.CLASSIC can be 1 or 0 - depending on Option Base
:)
 
Right

Try this
\\\
Dim dtr(10) As DateTime
dtr(0) = Now
dtr(10) = Now.AddDays(-1)
///

Cor
 
Next since you are using an array it's elements are from 0 to 9 in your
example. Your code from 1 to 10 will not work.

No, his array is 0 to 10, so iterating from 1 to 10 will work,
although the first element is wasted.
 
No, his array is 0 to 10, so iterating from 1 to 10 will work,
although the first element is wasted.







- Show quoted text -

The UDT "typClient" and "typCliSelect" was a typo, it was all
inteneded to be "typCliSelect"
I think what I have found is that setting A = B is the correct way to
set all properties of A = B, but the wizard throws an error. And in
this case should be ignored.
 
Back
Top