imports system.windows.forms imports microsoft.visualbasic imports system imports system.drawing class BinnsViewer inherits form dim pb as picturebox dim mm as mainMenu dim file as menuitem dim withevents open as menuitem dim withevents quit as menuitem public sub new() mybase.new() me.icon = new Icon(me.getType(), "bp.ico") me.location = new point(10,10) pb = new picturebox() pb.location = new point(20,20) me.controls.add(pb) mm = new mainMenu() me.menu = mm open = new menuitem() open.text = "Open" file = new menuitem() file.text = "File" quit = new menuitem() quit.text = "Quit" mm.menuitems.add(file) file.menuitems.add(open) file.menuitems.add("-") file.menuitems.add(quit) me.backcolor = systemcolors.controldark me.text = "BinnsViewer" end sub public sub new(path as string) me.new() showImage(path) end sub private sub openClicked(sender as object, e as eventargs) handles open.click dim ofd as openfiledialog = new openfiledialog() ofd.filter = "Picture Files|*.jpg" ofd.showDialog() showImage(ofd.filename) end sub private sub showImage(path as string) try pb.image = new bitmap(path) pb.height = pb.image.height pb.width = pb.image.width me.height = pb.image.height + 55 + 40 me.width = pb.image.width + 10 + 40 catch e as exception msgbox("Error loading image") end try end sub private sub quitClicked(sender as object, e as eventargs) handles quit.click dispose() end sub shared sub main(args as string()) if args.length > 0 then application.run(new BinnsViewer(args(0))) else application.run(new BinnsViewer()) end if end sub end class