0

been struggling to find a solution to this...

What is the equivalent of the following c# in vb?

var v = something as control;

Been trying for a while and haven't really found much, the following is what i have managed to get to so far.

If TypeOf ctrl Is Control Then
   'what to put here? 
   ctrl = ctrl as control??? 'nope...      
End If
SBeynon
  • 81
  • 1
  • 9

2 Answers2

1

have you tried

If TypeOf ctrl Is Control Then
   ctrl = Directcast(ctrl, control)
End If
  • No, but same as the answer i've just found, Thanks for the reply :) – SBeynon Jun 05 '14 at 11:05
  • 2
    this may provide useful info as well [link](http://stackoverflow.com/questions/3056514/difference-between-directcast-and-ctype-in-vb-net) –  Jun 05 '14 at 11:07
0

Found a solution that seems to work well.

If TypeOf ctrl Is Control Then
    ctrl = CType(ctrl, Control)
End If

using explicit Casting.

SBeynon
  • 81
  • 1
  • 9