Convert to VB.NET

Not sure if this should be in the C# area or here, but nonetheless here's what I'd like to convert to VB.NET:

public void btnCloseTask_Click(object sender, System.EventArgs e)
     Button myButton = sender as Button;
     Response.Write("<script>alert(" + myButton.CommandArgument + ")</script>");
     //Redirect code goes here

Here's how far I've gotten:

Public Sub btnCloseTask_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim myButton As Button  ' here I want to set myButton equal to sender.  However, sender is of type Object; I need to cast
                                        ' sender to a Button and set it to myButton
    Response.Write("<script>alert(" + myButton.CommandArgument + ")</script>")
End Sub

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
Hi martie_11,

Dim myButton As Button = CType(sender,Button)

Tim Cottee

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
martie_11Author Commented:
I thought it would be easy : )

Public Sub btnCloseTask_Click(ByVal sender As Object, ByVal e As System.EventArgs)
 Dim myButton As Button = CType(ConversionHelpers.AsWorkaround(sender, GetType(Button)), Button)
 Response.Write("<script>alert(" + myButton.CommandArgument + ")</script>")
End Sub

ran through a converter, basically what timcottee stated... figure I would post it though
martie_11Author Commented:
Thanks for the post bman9111.

I didn't test Tim's code, but if it doesn't work and yours does, I'll open another Q and give some points to you.

BTW, what converter are you using?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.