Convert to VB.NET

  • Thread starter Thread starter Keith
  • Start date Start date
K

Keith

I'm trying to iterate through the controls on the form -
to find the control with "focus". Someone (Tim) referred
me to the code below - which is in C# I don't really
follow it - can someone lend a hand and convert it to
VB.NET. Thank you.

public virtual Control ActiveControl
{
get
{
return GetFocusedControl(this);
}
set
{
if (!value.Focused)
{
value.Focus();
}
}
}

private Control GetFocusedControl(Control parent)
{
if (parent.Focused)
{
return parent;
}
foreach (Control ctrl in parent.Controls)
{
Control temp = GetFocusedControl(ctrl);
if (temp != null)
{
return temp;
}
} return null;
}
 
It would help you if you learned to read C#. Samples of the more technical
concepts (not this code snippet) seem to be in C#. It's not that hard. Half
the code now is the Framework, which is the same regardless of language.

good luck,
kevin aubuchon

public property ActiveControl as Control
get
return GetFocusedControl ( me)
end get
set
if Value.Focused = False then
Value.Focus()
end if
end set
end property
 
I agree with you Kevin. Any good C# books - you could
recommend for newbies. I need to learn C#. It seems you
can do much more from C# than from VB.NET.
 
Beginning C# from Wrox Press is very readable.

You might also look into some code converters to help you see sode-by-sides
of the two languages. There's one over at ragingsmurf.com
 
You might also look into some code converters to help you see sode-by-sides
of the two languages. There's one over at ragingsmurf.com

You could also try a disassembler like Lutz Roeder's Reflector (A must
have for any .NET developer's toolbox imho). It will allow you to
disassemble - non obfuscated - .NET assemblies into the language of your
choice.

Anakrino is another good one to look at.
 
Back
Top