473,765 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create new "me"

Hi,

Instead of doing this....
Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Form1
f.Show()
End Sub
End Class

I would like to make it generic by doing something like...

Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Me
f.Show()
End Sub
End Class

.... but "Me" is not accepted, neither is "Dim f As New TypeOf(Me)".

I would like to put the CreateAndShow in a base form and then inherit from
it and still be able to use the CreateAndShow method.

Any suggestions? TANKS!!! :o)

M O J O
Sep 29 '06
24 2839
Well then, too bad you need to go that route to gain any sense of self
worth. It would be so much better had you never answered this person's post
than belittle them. Shame does not teach. I used to do the same self-serving
kind of belittling that you know do but I rose above it to be able to give
greater support to more people. Perhaps someday, you'll try the same
"GhostInAK" <gh*******@gmai l.comwrote in message
news:be******** *************** ***@news.micros oft.com...
Hello Steve,

I'll berate whoever I want. Must you be so freakin sensitive? Grow a
pair, ya pansy.

-Boo
>-Boo,
Must you berate everyone?
"GhostInAK" <gh*******@gmai l.comwrote in message
news:be******* *************** ****@news.micro soft.com...
>>Hello M O J O,

What's the point of this? If the goal is to not have to call .Show
when you create a form (lazy-ass).. then add Me.Show to the base
form's ctor. -Boo

Hi,

Instead of doing this....

Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Form1
f.Show()
End Sub
End Class
I would like to make it generic by doing something like...
Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Me
f.Show()
End Sub
End Class
... but "Me" is not accepted, neither is "Dim f As New TypeOf(Me)".
I would like to put the CreateAndShow in a base form and then
inherit from it and still be able to use the CreateAndShow method.

Any suggestions? TANKS!!! :o)

M O J O


Oct 2 '06 #21
Perhaps your right mg. Also, perhaps he's never heard the saying, "people
don't care what you know until they know you care."
"mg" <bi*****@gmail. comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Watching Boo's replies to this and another recent post about retaining
changed values of a textbox, I think I see the reason. Boo does not
post to this NG to actually help anyone with VB, he's only here to show
everyone how much he knows. So if someone posts a question where he
can't do that, it shows in the caustic reply.

Boo, if the SNR is too high for you here, ignore it. As this is a
public NG, you are going to get all kinds of clueless nubes posting
stupid questions. Find a better way to deal with it so you can play
nicely.

GhostInAK wrote:
>Hello Steve,

I'll berate whoever I want. Must you be so freakin sensitive? Grow a
pair,
ya pansy.

-Boo
-Boo,
Must you berate everyone?
"GhostInAK" <gh*******@gmai l.comwrote in message
news:be******** *************** ***@news.micros oft.com...

Hello M O J O,

What's the point of this? If the goal is to not have to call .Show
when you create a form (lazy-ass).. then add Me.Show to the base
form's ctor. -Boo
>>Any suggestions? TANKS!!! :o)

M O J O

Oct 2 '06 #22
Mojo,

Public class myform
Inherits myBaseForm

https://msdn.microsoft.com/library/d...tminherits.asp

Cor

"M O J O" <MO**@discussio ns.microsoft.co mschreef in bericht
news:17******** *************** ***********@mic rosoft.com...
Hi Cor,

I was hoping that since my shared sub was inside a class, vb somehow new
what type of class the shared sub was called from.

I'm building a CRM system for my company. I want to have a base form that
can inherit all my form from. This base form will have many base stuff
....
forexample I will have three diferent ways to create and show a form ...

1) Normal - just create the form and show it.

2) Single instance - if the form is not yet created, create the form an
show
it.

3) Single instance by ID - if for example the customer-form with customer
ID=xxx is not showing, create the form and show it, else show it.

Hope you get my pont.

Here's my code so far (beware of wrappings)....
Public Class BaseForm

Private _singleInstance ID As Guid
Private Shared _singleInstance s As Dictionary(Of Guid, BaseForm)
Public Shared Sub CreateAndShowNo rmal(Optional ByVal owner As
IWin32Window = Nothing)
Dim f As Object =
Activator.Creat eInstance(Refle ction.MethodBas e.GetCurrentMet hod.DeclaringTy pe)
DirectCast(f, BaseForm).Show( owner)
End Sub
Public Shared Sub CreateAndShowSi ngleInstace(Opt ional ByVal owner As
IWin32Window = Nothing)
Call CreateAndShowSi ngleInstace(Gui d.Empty, owner)
End Sub
Public Shared Sub CreateAndShowSi ngleInstace(ByV al ID As Guid, Optional
ByVal owner As IWin32Window = Nothing)
If _singleInstance s Is Nothing Then
_singleInstance s = New Dictionary(Of Guid, BaseForm)
End If

Dim f As BaseForm

If Not _singleInstance s.ContainsKey(I D) Then
Dim fa As Object =
Activator.Creat eInstance(Refle ction.MethodBas e.GetCurrentMet hod.DeclaringTy pe)
f = DirectCast(fa, BaseForm)
f._singleInstan ceID = ID
_singleInstance s.Add(ID, f)
AddHandler f.FormClosed, AddressOf SingleInstanceC losed
Else
f = _singleInstance s(ID)
End If

f.Show()
f.Focus()
End Sub
Private Shared Sub SingleInstanceC losed(ByVal sender As Object, ByVal e
As FormClosedEvent Args)
_singleInstance s.Remove(Direct Cast(sender,
BaseForm)._sing leInstanceID)
End Sub

End Class
If there's a better way to do it, please let me know.

Thanks!

:o)

M O J O

"Cor Ligthert [MVP]" wrote:
>Mojo,

It is possible to create objects from classes. But never objects from
objects. (Although object is a class itself as well. To be more precise
the
highest class from which every thing derives).

The startup form is a kind of strange thing in VB.Net (but handy) it has
inbuild a Sub main, where in it creates an object from itself. For the
same
case you use a Module or Shared Class in which you can create your form
object. Than you can create as much objects from that class as you wish.

I hope this gives an idea.

Cor

"M O J O" <MO**@discussio ns.microsoft.co mschreef in bericht
news:88******* *************** ************@mi crosoft.com...
Hi,

Instead of doing this....
Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Form1
f.Show()
End Sub
End Class

I would like to make it generic by doing something like...

Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Me
f.Show()
End Sub
End Class

... but "Me" is not accepted, neither is "Dim f As New TypeOf(Me)".

I would like to put the CreateAndShow in a base form and then inherit
from
it and still be able to use the CreateAndShow method.

Any suggestions? TANKS!!! :o)

M O J O



Oct 2 '06 #23
Hello M O J O,

Ewwww.. YUCK.
Just use the .Show method with the Me keyword in your base form's ctor (to
hell with the shared functions). All that reflection gunk is noisy and ugly.

Public Sub New()
Me.Show()
End Sub

....Or better yet, stop bein a lazy-ass and call .Show yourself when you create
the form.

-Boo
Hi Boo,

Please see my reply to Cor.

:o)

M O J O

"GhostInAK" wrote:
>Hello M O J O,

What's the point of this? If the goal is to not have to call .Show
when you create a form (lazy-ass).. then add Me.Show to the base
form's ctor.

-Boo
>>Hi,

Instead of doing this....

Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Form1
f.Show()
End Sub
End Class
I would like to make it generic by doing something like...
Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Me
f.Show()
End Sub
End Class
... but "Me" is not accepted, neither is "Dim f As New TypeOf(Me)".
I would like to put the CreateAndShow in a base form and then
inherit from it and still be able to use the CreateAndShow method.

Any suggestions? TANKS!!! :o)

M O J O


Oct 3 '06 #24
hey it is me so give me a shout!!

*** Sent via Developersdex http://www.developersdex.com ***
Oct 14 '06 #25

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2174
by: Luis | last post by:
the assignment is to count the number of words in a txt file here is my code #include <iostream> #include <fstream> #include <cassert> using namespace std; int main () {
1
6803
by: RC | last post by:
If I want to explicitly save the record before executing a Close action. Which of the following should I use? Or does it depend on whether it is based on a Form or something else? If Me.Dirty Then RunCommand acCmdSaveRecord End If DoCmd.Close or
1
3085
by: RzB | last post by:
In a previous post in this NG (Oct 98) http://makeashorterlink.com/?D505347FB Henry Craven says that he was investigating a relationship between the presence or absence of a "Me!" prefix, the value of the Top propery of a control, and the occurrence of an invalid runtime error "The control or subform control is too large for this location"
3
5291
by: TCORDON | last post by:
Can someone give me a sample or point me in the direction of one, on how to implement User "Remember Me" option when logging into a website? TIA
0
1273
by: Michael Fitzpatrick | last post by:
I have a .NET application with an installer. The customer wants the install page with the "Everyone" or "Just Me" selection to default to "Everyone". Presently it defaults to "Just Me". Any hints on how I can achieve this? -- : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - : my email address zfarjf@pbqrvafvtug.com is encrypted with www.rot13.org
1
6497
by: acool | last post by:
I just created a simple Windows Service in VB.NET. I right clicked on the component and added the installer, installed via InstallUtil.exe all went well until i try to do a net start and then I get: "the service name is invalid" WHY??
5
1571
by: Agnes | last post by:
For my own practices. I like to put "Me". e.g IF Me.txtInvoice.textlength = 0 ....... etc Me.txt.....etc However, Is there any difference (without Me) ?? Thanks
1
12588
by: ImageAnalyst | last post by:
Yay!!! They fixed this for VS2005. You can now set the default installation to be "Everyone" instead of "Just Me" and you can control whether you even want those radio button installed in your Setup program. >From the Documentation http://msdn2.microsoft.com/en-us/library/5f981xa1.aspx =========================================================== "The InstallAllUsers property for a deployment project determines whether an application is...
1
2298
by: Ray | last post by:
Hello, Please help a VB newbie :) I'm a bit confused, reading all the MyClass, Me, My keywords of VB. I think I get MyClass and My, but Me... Can you just tell me if I get this correctly? "Me" in VB (6, 7, 2005) is exactly like "this" in C# or C++. Its meaning hasn't changed since VB 6. True or False? Many thanks,
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.