473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

what is DefInstance.

Cal
I converted a vb6 app and it now contains many instances of DefInstance. As
in:

CAG.frmMDINamespace.frmMDI.DefInstance.mnuApplicat ionItem(glngSET_DEFAULT_PR
INTER_ITEM).Checked = False

Can anyone tell me what the property means? I've been looking in MSDN but
can't find out.

Thanks
Nov 20 '05 #1
4 6873
Hi Cal,

In VB6 if you create a Form, eg frmCal, you can access the Form and it's Controls, Properties, etc using that name -
frmCal.

In VB.NET you can't!! In VB.NET, frmCal is the name of the class <only> and you must instantiate that class and use the
object thus created. The trouble is there's no such variable unless you create one explicitly.

When converting a VB6 project to VB.NET, the converter (I hesitate to use that word 'wizard') creates a Shared member
of the class called DefInstance to which it assigns the reference to the Form instance that it creates.

Something like:
Class frmCal
Public Shared DefInstance As frmCal

Public Sub New
DefInstance = Me

If you have frmCal.TextBox1 in your code, for instance, it won't behave the way that you would expect from knowing VB6.
Most often it will bark at you (reference to a non shared member). The working equivalent is frmCal.DefInstance.TextBox1.

This method only works for Form classes which will only have one instance. DefInstance <is> that one.

Regards,
Fergus
Nov 20 '05 #2
* "Cal" <ac****@REMOVEa-znet.com> scripsit:
I converted a vb6 app and it now contains many instances of DefInstance. As
in:

CAG.frmMDINamespace.frmMDI.DefInstance.mnuApplicat ionItem(glngSET_DEFAULT_PR
INTER_ITEM).Checked = False

Can anyone tell me what the property means? I've been looking in MSDN but
can't find out.


It will return the default instance of the class 'frmMDI'. In VB
Classic the default instance could be accessed by the name of the class,
that's not possible in VB.NET any more.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #3
Cal
Thanks - very thorough

Cal

"Fergus Cooney" <fi****@post.com> wrote in message
news:e4**************@TK2MSFTNGP12.phx.gbl...
Hi Cal,

In VB6 if you create a Form, eg frmCal, you can access the Form and it's Controls, Properties, etc using that name - frmCal.

In VB.NET you can't!! In VB.NET, frmCal is the name of the class <only> and you must instantiate that class and use the object thus created. The trouble is there's no such variable unless you create one explicitly.
When converting a VB6 project to VB.NET, the converter (I hesitate to use that word 'wizard') creates a Shared member of the class called DefInstance to which it assigns the reference to the Form instance that it creates.
Something like:
Class frmCal
Public Shared DefInstance As frmCal

Public Sub New
DefInstance = Me

If you have frmCal.TextBox1 in your code, for instance, it won't behave the way that you would expect from knowing VB6. Most often it will bark at you (reference to a non shared member). The working equivalent is frmCal.DefInstance.TextBox1.
This method only works for Form classes which will only have one instance. DefInstance <is> that one.
Regards,
Fergus

Nov 20 '05 #4
"Cal" <ac****@REMOVEa-znet.com> schrieb
I converted a vb6 app and it now contains many instances of
DefInstance. As in:

CAG.frmMDINamespace.frmMDI.DefInstance.mnuApplicat ionItem(glngSET_DEFAULT_PR INTER_ITEM).Checked = False

Can anyone tell me what the property means? I've been looking in
MSDN but can't find out.


That's the "simulation" of the default instance that VB6 automatically
declares/creates for each Form in the project.
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #5

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

Similar topics

2
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
12
by: Dario | last post by:
The following simple program behaves differently in Windows and Linux . #include <stdexcept> #include <iostream> #include <string> using namespace std; class LogicError : public logic_error {...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
2
by: vijayB | last post by:
Hi All, I have one application designed in VB6.0, and now I've converted it into VB.NET application. I am using visual studio 2003. After conversion it is having too many shared properties...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.