Need to convert C# code to VB.NET

  • Thread starter Thread starter Joe Book
  • Start date Start date
J

Joe Book

I am trying to covert the following code to VB.NET. This code is
using reflection to auto size the columns of a grid. Unfortunately, I
am not familiar with C#. I have tried the various code converters and
the first three lines convert very nicely but it chokes on line within
the loop. Any help?


Type t = dgRows.GetType();
MethodInfo m = t.GetMethod("ColAutoResize",BindingFlags.NonPublic);
for (int i = dgRows.FirstVisibleColumn; (i <
dgLogging.VisibleColumnCount); i++)
{
m.Invoke(dgRows, new object[]{i});
}
 
Joe Book said:
I am trying to covert the following code to VB.NET. This code is
using reflection to auto size the columns of a grid. Unfortunately, I
am not familiar with C#. I have tried the various code converters and
the first three lines convert very nicely but it chokes on line within
the loop. Any help?


Type t = dgRows.GetType();
MethodInfo m = t.GetMethod("ColAutoResize",BindingFlags.NonPublic);
for (int i = dgRows.FirstVisibleColumn; (i <
dgLogging.VisibleColumnCount); i++)
{
m.Invoke(dgRows, new object[]{i});
}

Hi Joe,

Dim t As Type = dgRows.GetType()
Dim m As MethodInfo = t.GetMethod("ColAutoResize", BindingFlags.NonPublic)
For i As Integer = dgRows.FirstVisibleColumn To dgLogging.VisibleColumnCount
m.Invoke(dgRows, New Object() {i})
Next

Cheers

Arne Janning
 
* (e-mail address removed) (Joe Book) scripsit:
I am trying to covert the following code to VB.NET. This code is
using reflection to auto size the columns of a grid. Unfortunately, I
am not familiar with C#. I have tried the various code converters and
the first three lines convert very nicely but it chokes on line within
the loop. Any help?

Type t = dgRows.GetType();
MethodInfo m = t.GetMethod("ColAutoResize",BindingFlags.NonPublic);
for (int i = dgRows.FirstVisibleColumn; (i <
dgLogging.VisibleColumnCount); i++)
{
m.Invoke(dgRows, new object[]{i});
}

\\\
Imports System.Reflection
..
..
..
Dim t As Type = dgRows.GetType()
Dim m As MethodInfo = t.GetMethod("ColAutoResize", BindingFlags.NonPublic)
Dim i As Integer
For i = dgRows.FirstVisibleColumn To dgLogging.VisibleColumnCount - 1
m.Invoke(dgRows, New Object() {i})
Next i
///
 
Herfried,

Strange some threads bellow I saw from you a statement that it was not
needed to convert from VBNet to C# and now you give in the oposite way the
code.

:-)

Cor
 
Cor,

* "Cor Ligthert said:
Strange some threads bellow I saw from you a statement that it was not
needed to convert from VBNet to C# and now you give in the oposite way the
code.

:-)

Really strange, isn't it ;-)...

C# -> VB.NET = :-).
VB.NET -> C# = :-(.
 
Back
Top