C# Conversion

S

Sueffel

Having a small problem figuring out how to convert the following structures
to VB:

[StructLayout(LayoutKind.Sequential, Pack = 4)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;

public override string ToString()
{
string ret = String.Format(
"left = {0}, top = {1}, right = {2}, bottom = {3}",
left, top, right, bottom);
return ret;
}
}

[StructLayout(LayoutKind.Sequential, Pack = 4)]
private struct PAINTSTRUCT
{
public IntPtr hdc;
public int fErase;
public RECT rcPaint;
public int fRestore;
public int fIncUpdate;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] public byte[]
rgbReserved;

public override string ToString()
{
string ret = String.Format(
"hdc = {0} , fErase = {1}, rcPaint = {2}, fRestore = {3}, fIncUpdate =
{4}",
hdc, fErase, rcPaint.ToString(), fRestore, fIncUpdate);
return ret;
}
}

Thanks,
Sueffel
 
N

Nick

http://www.kamalpatel.net/ConvertCSharp2VB.aspx

<StructLayout(LayoutKind.Sequential, Pack = 4)> _
Private Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer

Public Overrides Function ToString() As String
String ret = String.Format(
"left = {0}, top = {1}, right = {2}, bottom = {3}",
left, top, right, bottom)
Return ret
End Function
End Structure

<StructLayout(LayoutKind.Sequential, Pack = 4)> _
Private Structure PAINTSTRUCT
Public hdc As IntPtr
Public fErase As Integer
Public rcPaint As RECT
Public fRestore As Integer
Public fIncUpdate As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst=32)> _ Public Byte()
rgbReserved
Public Overrides Function ToString() As String
String ret = String.Format("hdc = {0}, fErase = {1}, rcPaint = {2},
fRestore = {3}, fIncUpdate ={4}",hdc, fErase, rcPaInteger.ToString(),
fRestore, fIncUpdate)
Return ret
End Function
End Structure

'----------------------------------------------------------------
' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (http://www.KamalPatel.net)
'----------------------------------------------------------------
 
S

Sueffel

Nick said:
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

<StructLayout(LayoutKind.Sequential, Pack = 4)> _
Private Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer

Public Overrides Function ToString() As String
String ret = String.Format(
"left = {0}, top = {1}, right = {2}, bottom = {3}",
left, top, right, bottom)
Return ret
End Function
End Structure

<StructLayout(LayoutKind.Sequential, Pack = 4)> _
Private Structure PAINTSTRUCT
Public hdc As IntPtr
Public fErase As Integer
Public rcPaint As RECT
Public fRestore As Integer
Public fIncUpdate As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst=32)> _ Public Byte()
rgbReserved
Public Overrides Function ToString() As String
String ret = String.Format("hdc = {0}, fErase = {1}, rcPaint = {2},
fRestore = {3}, fIncUpdate ={4}",hdc, fErase, rcPaInteger.ToString(),
fRestore, fIncUpdate)
Return ret
End Function
End Structure

'----------------------------------------------------------------
' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (http://www.KamalPatel.net)
'----------------------------------------------------------------

Sueffel said:
Having a small problem figuring out how to convert the following structures
to VB:

[StructLayout(LayoutKind.Sequential, Pack = 4)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;

public override string ToString()
{
string ret = String.Format(
"left = {0}, top = {1}, right = {2}, bottom = {3}",
left, top, right, bottom);
return ret;
}
}

[StructLayout(LayoutKind.Sequential, Pack = 4)]
private struct PAINTSTRUCT
{
public IntPtr hdc;
public int fErase;
public RECT rcPaint;
public int fRestore;
public int fIncUpdate;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] public byte[]
rgbReserved;

public override string ToString()
{
string ret = String.Format(
"hdc = {0} , fErase = {1}, rcPaint = {2}, fRestore = {3},
fIncUpdate
=
{4}",
hdc, fErase, rcPaint.ToString(), fRestore, fIncUpdate);
return ret;
}
}

Thanks,
Sueffel

Thank you, the site helps alot!
Still having some issues, but it is just some minor differences between the
two languages. In case your wondering, I'm converting the Painting the MDI
Client Area example from VBAccelerator.com from C# to VB.NET. Soo much
fuin...

Thanks Again,
Sueffel
 

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