?
Solved

How can I suppress a form's native subroutine (show method) and replace it with several overloads (do I use shadow?)

Posted on 2009-12-17
5
Medium Priority
?
200 Views
Last Modified: 2012-05-08
I want to replace my form's native "show" method with several overloaded subroutines that I've built.  I want to make sure that the native 'show' routine can not be seen.  Will shadow do this?
0
Comment
Question by:David L. Hansen
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
x77 earned 1000 total points
ID: 26073461
Yes you can

      Shadows Sub Show()
         MessageBox.Show("Ok")
         MyBase.Show()
      End Sub

      Shadows Function ShowDialog() As DialogResult
         MessageBox.Show("Ok")
         Return MyBase.ShowDialog
      End Function

But if it is the main Window and you has selected it as initial Form in the application panel, Form.Show is called.
0
 
LVL 15

Expert Comment

by:x77
ID: 26073501
Also if your form is Form1 then
  Directcast(Form1,Form).Show  - bypass Shadow Function.
0
 
LVL 15

Author Comment

by:David L. Hansen
ID: 26073977
I'm curious about something: if I have one routine that overloades the native 'Show' sub I have to use the 'Overloads' keyword (the ide forces me to).  I guess that's because I'm not just overloading my own custom routine but a native .net routine.  Now, I would have assumed that in the case where I'm not only overloading the native routine but also shadowing it, that I'd have to use both keywords: 'Overloads' and 'Shadows' in the declaration (especially since I have several 'Show' subs that I'm inserting) .  I see however that the IDE doesn't force me to do that though; any idea why?
0
 
LVL 15

Expert Comment

by:x77
ID: 26074103
When a sub or Function is declared as overridable, then is a Virtual Function (Called by Reference).
If you overrides the Function, the overrided method is called.
You can also in this case call MyBase.OveridedFunction. It calls it on No Virtual mode.

If you Shadows or overloads a function, yo can each Shadowed or not sadowed Functions
In this case you have Form.Show and also Form1.Show functions.

Dim f as Form = New Form1.
F.Show - Calls Form.Show not Form1.Show
0
 
LVL 15

Author Closing Comment

by:David L. Hansen
ID: 31667384
Thank you very much.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question