VB to C#

N

Nikolay Petrov

Please, can someone convert the following C# code to VB .NET
As far as I can see there are some errors in it, but I am not sure.


if (WTSEnumerateSessions(IntPtr.Zero, 0, 1, ref buffer, ref count))
{
WTS_SESSION_INFO[] sessionInfo = new WTS_SESSION_INFO[count];
for (int index = 0; index < count; index++)
sessionInfo[index] = Marshal.PtrToStructure(buffer +
(sizeof(WTS_SESSION_INFO) * index), typeof(WTS_SESSION_INFO));



TIA
 
H

Herfried K. Wagner [MVP]

Nikolay Petrov said:
Please, can someone convert the following C# code to VB .NET
As far as I can see there are some errors in it, but I am not sure.

if (WTSEnumerateSessions(IntPtr.Zero, 0, 1, ref buffer, ref count))
{
WTS_SESSION_INFO[] sessionInfo = new WTS_SESSION_INFO[count];
for (int index = 0; index < count; index++)
sessionInfo[index] = Marshal.PtrToStructure(buffer +
(sizeof(WTS_SESSION_INFO) * index), typeof(WTS_SESSION_INFO));

\\\
If WTSEnumerateSessions(IntPtr.Zero, 0, 1, Buffer, count) Then
Dim sessionInfo(count - 1) As WTS_SESSION_INFO
For index As Integer = 0 To count - 1
sessionInfo(index) = Marshal.PtrToStructure(New IntPtr(buffer +
(Marshal.SizeOf(GetType(WTS_SESSION_INFO)) * index)),
GetType(WTS_SESSION_INFO))
Next index
End If
///

For a good C# to VB.NET converter take a look here:

Instant VB
<URL:http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_VB/Instant_VB.htm>
 
N

Nikolay Petrov

What about converting code with errors?



Herfried K. Wagner said:
Nikolay Petrov said:
Please, can someone convert the following C# code to VB .NET
As far as I can see there are some errors in it, but I am not sure.

if (WTSEnumerateSessions(IntPtr.Zero, 0, 1, ref buffer, ref count))
{
WTS_SESSION_INFO[] sessionInfo = new WTS_SESSION_INFO[count];
for (int index = 0; index < count; index++)
sessionInfo[index] = Marshal.PtrToStructure(buffer +
(sizeof(WTS_SESSION_INFO) * index), typeof(WTS_SESSION_INFO));

\\\
If WTSEnumerateSessions(IntPtr.Zero, 0, 1, Buffer, count) Then
Dim sessionInfo(count - 1) As WTS_SESSION_INFO
For index As Integer = 0 To count - 1
sessionInfo(index) = Marshal.PtrToStructure(New IntPtr(buffer +
(Marshal.SizeOf(GetType(WTS_SESSION_INFO)) * index)),
GetType(WTS_SESSION_INFO))
Next index
End If
///

For a good C# to VB.NET converter take a look here:

Instant VB
<URL:http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_VB/Instant_VB.htm>
 
G

Guest

Our converters (Instant C# and Instant VB) are able to convert incomplete
code with a high success rate - i.e., code snippets with variables or methods
defined elsewhere. However, if you have code which has errors in syntax,
then we make no predictions - it may convert, or fail miserably. Correct
syntax is necessary to allow parsing to succeed.

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com

Nikolay Petrov said:
What about converting code with errors?



Herfried K. Wagner said:
Nikolay Petrov said:
Please, can someone convert the following C# code to VB .NET
As far as I can see there are some errors in it, but I am not sure.

if (WTSEnumerateSessions(IntPtr.Zero, 0, 1, ref buffer, ref count))
{
WTS_SESSION_INFO[] sessionInfo = new WTS_SESSION_INFO[count];
for (int index = 0; index < count; index++)
sessionInfo[index] = Marshal.PtrToStructure(buffer +
(sizeof(WTS_SESSION_INFO) * index), typeof(WTS_SESSION_INFO));

\\\
If WTSEnumerateSessions(IntPtr.Zero, 0, 1, Buffer, count) Then
Dim sessionInfo(count - 1) As WTS_SESSION_INFO
For index As Integer = 0 To count - 1
sessionInfo(index) = Marshal.PtrToStructure(New IntPtr(buffer +
(Marshal.SizeOf(GetType(WTS_SESSION_INFO)) * index)),
GetType(WTS_SESSION_INFO))
Next index
End If
///

For a good C# to VB.NET converter take a look here:

Instant VB
<URL:http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_VB/Instant_VB.htm>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top