Search code examples
vb.netcasting

Casting in visual basic?


I want to check multiple controls state in one method, in C# this would be accomplished like so:

if (((CheckBox)sender).Checked == true)
{
    // Do something...
}
else
{
    // Do something else...
}

So how can I accomplish this in VB?


Solution

  • C#:

    (CheckBox)sender
    

    VB:

    CType(sender, CheckBox)