Ok, so you have used VB6 for years but suddenly you have migrated to VB.NET and don't have a clue... i have put this together to help get you started
the biggest issue you will have is forms... forms are no longer magically existant, they must be instantiated and have references passed to each other to access them.
here is a tutorial for using multiple forms: http://www.devcity.net/Articles/94/1/multipleforms.aspx (compliments of gigemboy)
but even before you visit there i recommend doing this simple exercise that will train you for instantiating objects. Control arrays no longer exist (you say)
never fear, we can make them ourselves at runtime if we like. Ok, here is how to make a control array of 5 buttons
Make 5 buttons on the form from code
but, that wont do the job.. what we have made is 5 empty "containers" for buttons, they need to be populated with an "instance" of an objectCode:Dim buttonArray(5) as Button
that will instantiate the first one, what you need to do is use a for loop to instantiate them all. Also give them x and y co-ords and make them visibleCode:buttonArray(0) = New Button
The next problem faced is hw on earth do i know if they are clicked?
first, make a sub ready to handle a button click event
notice the layout is the same as any other button click event, it must have the same variablesCode:Sub ButtonArray_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) 'sender will be the button that was clicked End Sub
now, in your for loop, you need to add a "handler" to link the buttons click event with that sub, doing so is as simple as
how do i know which one is clicked?Code:AddHandler ButtonArray(0).Click, AddressOf ButtonArray_Click
well, you may notice i noted that "sender" will be the button that was clicked.. but it is of type Object so how can we use it? this is yet another hurdle, object is the general type of all classes.. but we know that for this particular sub, it will always be a Button, so we can safety DirectCast it into a Button (As an object it is still a button.. but it doesnt know that it is, basically)
To extend on this simple array, experiment with using an ArrayList, declaring it at form level "Private ButtonArray As New ArrayList" so that you can add and remove controls from it at will.Code:Sub ButtonArray_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) 'sender will be the button that was clicked (in object form) Dim buttonClicked as Button = DirectCast(sender,Button) 'now buttonClicked is the sender object in its correct Button form End Sub
If you are into graphics, when it comes time, don't use bltbit, readup on GDI+, included in .NET and very useful, do a search on this site for it.
Good Luck![]()


you say)
Multi-Clipboard
Reply With Quote
vbforums results come within top 5 on google many times if it contains specific information.
