GPS API

  • Thread starter Thread starter Joseph Byrns
  • Start date Start date
J

Joseph Byrns

I am going through the managed GPS example and trying to convert all the
bits to VB.NET but I have a couple of translation problems if anyone can
advise:

for (int viewIndex = 0; viewIndex < inViewSatellites.Length && found ==
null; viewIndex++)
(no idea what the && found == null bit does)

public bool SatellitesInViewValid
{
get { return (dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) != 0; }
}

I have translated this as:
Public ReadOnly Property SatellitesInViewValid() As Boolean
Get
Return CType((dwValidFields And GPS_VALID_SATELLITES_IN_VIEW),
Boolean)
End Get
End Property

but don't understand what the !=0 is doing????

And finally in a structure there is a property declared as:
public int this[int value]
How does this translate??

Thanks.
 
1.
--
The '&& found == null' bit translates to 'AndAlso found Is Nothing'.

As a complicating factor, one can't 'mix n match' a For-Next loop limit.
Therefore an appropriate translation is:

For viewIndex As Integer = 0 To inViewSatellites.Length -1
If found IsNot Nothing Then Exit For
 
Thanks,

That was the only bit left I was having difficulty with.

Stephany Young said:
1.
--
The '&& found == null' bit translates to 'AndAlso found Is Nothing'.

As a complicating factor, one can't 'mix n match' a For-Next loop limit.
Therefore an appropriate translation is:

For viewIndex As Integer = 0 To inViewSatellites.Length -1
If found IsNot Nothing Then Exit For
.
.
.
Next

2.
--
And'ing two values gives a value rather than a boolean. In VB one can get
away with the fact that a non-zero value will equate to false if a boolean
test is applied to it, but more correctly the test should be to see if the
result is zero or not. Therefore the appropriate translation is:

Public ReadOnly Property SatellitesInViewValid() As Boolean
Get
Return ((dwValidFields And GPS_VALID_SATELLITES_IN_VIEW) <> 0)
End Get
End Property

3.
--
This indicates a default property accessed with an indexer. An appropriate
translation is:

Public ReadOnly Default Property Xxxx(ByVal Value as Integer) As
Integer
Get
Return MyCollection(Value)
End Get
End Property


Joseph Byrns said:
I am going through the managed GPS example and trying to convert all the
bits to VB.NET but I have a couple of translation problems if anyone can
advise:

for (int viewIndex = 0; viewIndex < inViewSatellites.Length && found ==
null; viewIndex++)
(no idea what the && found == null bit does)

public bool SatellitesInViewValid
{
get { return (dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) != 0; }
}

I have translated this as:
Public ReadOnly Property SatellitesInViewValid() As Boolean
Get
Return CType((dwValidFields And GPS_VALID_SATELLITES_IN_VIEW),
Boolean)
End Get
End Property

but don't understand what the !=0 is doing????

And finally in a structure there is a property declared as:
public int this[int value]
How does this translate??

Thanks.
 
Thanks, got the default property working nicely.

Sergey Bogdanov said:
See the table below:

C# VB
____________________
&&, & And
!= 0 <> 0
null Nothing
this Me


What concerning "int this[index]" is you have to consider the Default
Properties in VB.NET:
http://msdn.microsoft.com/library/d...n-us/vbcn7/html/vbconPastingCodeFragments.asp



--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


Joseph said:
I am going through the managed GPS example and trying to convert all the
bits to VB.NET but I have a couple of translation problems if anyone can
advise:

for (int viewIndex = 0; viewIndex < inViewSatellites.Length && found ==
null; viewIndex++)
(no idea what the && found == null bit does)

public bool SatellitesInViewValid
{
get { return (dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) != 0; }
}

I have translated this as:
Public ReadOnly Property SatellitesInViewValid() As Boolean
Get
Return CType((dwValidFields And GPS_VALID_SATELLITES_IN_VIEW),
Boolean)
End Get
End Property

but don't understand what the !=0 is doing????

And finally in a structure there is a property declared as:
public int this[int value]
How does this translate??

Thanks.
 
This part that is.

Thanks again.

Joseph Byrns said:
Thanks,

That was the only bit left I was having difficulty with.

Stephany Young said:
1.
--
The '&& found == null' bit translates to 'AndAlso found Is Nothing'.

As a complicating factor, one can't 'mix n match' a For-Next loop limit.
Therefore an appropriate translation is:

For viewIndex As Integer = 0 To inViewSatellites.Length -1
If found IsNot Nothing Then Exit For
.
.
.
Next

2.
--
And'ing two values gives a value rather than a boolean. In VB one can get
away with the fact that a non-zero value will equate to false if a
boolean test is applied to it, but more correctly the test should be to
see if the result is zero or not. Therefore the appropriate translation
is:

Public ReadOnly Property SatellitesInViewValid() As Boolean
Get
Return ((dwValidFields And GPS_VALID_SATELLITES_IN_VIEW) <> 0)
End Get
End Property

3.
--
This indicates a default property accessed with an indexer. An
appropriate translation is:

Public ReadOnly Default Property Xxxx(ByVal Value as Integer) As
Integer
Get
Return MyCollection(Value)
End Get
End Property


Joseph Byrns said:
I am going through the managed GPS example and trying to convert all the
bits to VB.NET but I have a couple of translation problems if anyone can
advise:

for (int viewIndex = 0; viewIndex < inViewSatellites.Length && found ==
null; viewIndex++)
(no idea what the && found == null bit does)

public bool SatellitesInViewValid
{
get { return (dwValidFields & GPS_VALID_SATELLITES_IN_VIEW) != 0; }
}

I have translated this as:
Public ReadOnly Property SatellitesInViewValid() As Boolean
Get
Return CType((dwValidFields And GPS_VALID_SATELLITES_IN_VIEW),
Boolean)
End Get
End Property

but don't understand what the !=0 is doing????

And finally in a structure there is a property declared as:
public int this[int value]
How does this translate??

Thanks.
 
Don't forget that there's more thatn one way to skin a cat.

Another way could be to use an While loop instead, thus:

Dim viewIndex As Integer = 0

While viewIndex < inViewSatellites.Length AndAlso found IsNot Nothing
 
Back
Top