Casting in visual basic?

前端 未结 5 1565
情书的邮戳
情书的邮戳 2020-12-16 16:26

I\'m a C# programmer who is forced to use VB (eh!!!!). I want to check multiple controls state in one method, in C# this would be accomplished like so:

if ((         


        
5条回答
  •  失恋的感觉
    2020-12-16 17:10

    Casting in VB.net uses the keyword ctype. So the C# statement (CheckBox)sender is equivalent to ctype(sender,CheckBox) in VB.net.

    Therefore your code in VB.net is:

    if ctype(sender,CheckBox).Checked =True Then
        ' Do something...
    else
        ' Do something else...
    End If
    

提交回复
热议问题