InterviewSolution
Saved Bookmarks
| 1. |
Solve : Instruction Dim in Visual Basic 6!!!? |
|
Answer» Hello everybody, I have a little clue about the attributes used in the instruction Dim. I would like to know what kind of function have the attribs As Form. The answer is "a form". I know it, but I need to get an explanation about its uses!!!!are you asking what purpose it would have to Dimension a variable of type Form?Quote from: BC_Programmer on July 04, 2008, 10:10:12 PM are you asking what purpose it would have to Dimension a variable of type Form? YES I do.Quote from: friny on July 07, 2008, 02:56:58 AM Quote from: BC_Programmer on July 04, 2008, 10:10:12 PMare you asking what purpose it would have to Dimension a variable of type Form? The idea is to PROVIDE something called polymorphism, say for example you have to following procedure: Code: [Select]Private Function ShowAndSize() Form1.Show Form1.Move (Screen.Width/2)-(Form1.Width/2),(Screen.Height/2)-(Form1.Height/2) End Function This works (shows the form and centers it on the screen, but you'll need to create a new function for any other form. Instead, we could do this: Code: [Select]Private Function ShowAndSize(FormSize As Form) FormSize.Show FormSize.Move (Screen.Width/2)-(FormSize.Width/2),(Screen.Height/2)-(FormSize.Height/2) End Function and then call it by passing the form as a parameter. Of course, that isn't really declaring a variable of type form- one POSSIBLE usage for such a thing would be for a form that is designed to work with another form, the "CHILD" form could keep a private variable of Type form that can be changed to determine the parent form. |
|