
Really dumb question about As
Hi. Despite speaking no VB, I was asked last week to produce a VB.NET
example of the use of an ActiveX control that a friend of mine built.
This has been a surprisingly pleasant experience -- I was expecting
the impossible part to be embedding the ActiveX control, whilst all I
had to do was drag-and-drop -- until I came to a Menu Problem.
I've got a menu zoomMenu with entries zoom50, zoom100, zoom150,
zoom200. At the moment, I have handlers looking like
... handles zoom50.Click
zoom50.Checked=true;
zoom100.Checked=false;
zoom150.Checked=false;
zoom200.Checked=false;
In C#, I could just do
foreach Menuitem t in zoomMenu.MenuItems {t.Checked = false;}
((MenuItem)sender).Checked = true;
I thought the second line translated into VB as
(sender As MenuItem).Checked = true;
but this gave weird syntax errors when compiled.
I couldn't find a suitable example in the documentation -- any query I
tried gave back five hundred answers, and when I looked through them
most of them seemed irrelevant. I realise this is a fundamental VB
question; I apologise for not knowing the language and hoping that I
could pick it up as I went along.