/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
VB6 Bug?
Fra : sjoerd


Dato : 23-07-03 11:35

Hi,

I have a problem in a MDI-project.
I declared a variable MyVarAA in frmMain.frm (Public MyVarAA) in the General
Declaration section)

I need this variable in Form1, so in the Form_Load of this form I wrote:

MyVarBB = frmMain.MyVarAA

When trying to run the program I get the following error:

Run-time error 426 (only one MDI-form allowed).

The debug-information tells me:

frmMain.MyVarAA = <object variable or with block variable not set>

Acoording to the book I use (Using Visual Basic 6) is this the way to do it.
Error in the Book? Bug in VB? Something else?

Thanks,

Sjoerd



 
 
Patrick Hayes (23-07-2003)
Kommentar
Fra : Patrick Hayes


Dato : 23-07-03 11:40

> Run-time error 426 (only one MDI-form allowed).

set Child property of Form1 ?

- patrick



sjoerd (23-07-2003)
Kommentar
Fra : sjoerd


Dato : 23-07-03 12:24

> > Run-time error 426 (only one MDI-form allowed).
>
> set Child property of Form1 ?
>
> - patrick
>
>

MDIChild = True

Sjoerd



Jan Hyde (23-07-2003)
Kommentar
Fra : Jan Hyde


Dato : 23-07-03 13:25

"sjoerd" <iwi@iwi.myweb.nl>'s wild thoughts were released on
Wed, 23 Jul 2003 12:35:00 +0200 bearing the following fruit:

>Hi,
>
>I have a problem in a MDI-project.
>I declared a variable MyVarAA in frmMain.frm (Public MyVarAA) in the General
>Declaration section)
>
>I need this variable in Form1, so in the Form_Load of this form I wrote:
>
>MyVarBB = frmMain.MyVarAA
>
>When trying to run the program I get the following error:
>
>Run-time error 426 (only one MDI-form allowed).
>
>The debug-information tells me:
>
>frmMain.MyVarAA = <object variable or with block variable not set>
>
>Acoording to the book I use (Using Visual Basic 6) is this the way to do it.
>Error in the Book? Bug in VB? Something else?
>
>Thanks,
>
>Sjoerd
>


Dim frm as frmMDIMain

'-- Load an instance of the MDI form
set frm = New FrmMDIMain
frm.Show
'-- Causes another instance of the MDI to load
frmMDIMain.Caption = "Ooops"
'-- Does not cause another instance to load
frm.Caption = "Correct'

J


--
So I said "Do you want a game of Darts?", he said "OK then", I said
"Nearest to bull starts". He said "Baa", I said "Moo", he said
"You're closest".

[Abolish the TV Licence - http://www.tvlicensing.biz/]


sjoerd (23-07-2003)
Kommentar
Fra : sjoerd


Dato : 23-07-03 20:33


"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
news:ohvshvk1jgtihtm0u278gjtpskd7e2k0me@4ax.com...
> "sjoerd" <iwi@iwi.myweb.nl>'s wild thoughts were released on
> Wed, 23 Jul 2003 12:35:00 +0200 bearing the following fruit:
>
> >Hi,
> >
> >I have a problem in a MDI-project.
> >I declared a variable MyVarAA in frmMain.frm (Public MyVarAA) in the
General
> >Declaration section)
> >
> >I need this variable in Form1, so in the Form_Load of this form I wrote:
> >
> >MyVarBB = frmMain.MyVarAA
> >
> >When trying to run the program I get the following error:
> >
> >Run-time error 426 (only one MDI-form allowed).
> >
> >The debug-information tells me:
> >
> >frmMain.MyVarAA = <object variable or with block variable not set>
> >
> >Acoording to the book I use (Using Visual Basic 6) is this the way to do
it.
> >Error in the Book? Bug in VB? Something else?
> >
> >Thanks,
> >
> >Sjoerd
> >
>
>
> Dim frm as frmMDIMain
>
> '-- Load an instance of the MDI form
> set frm = New FrmMDIMain
> frm.Show
> '-- Causes another instance of the MDI to load
> frmMDIMain.Caption = "Ooops"
> '-- Does not cause another instance to load
> frm.Caption = "Correct'
>
> J
>
>
> --
> So I said "Do you want a game of Darts?", he said "OK then", I said
> "Nearest to bull starts". He said "Baa", I said "Moo", he said
> "You're closest".
>
> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>

Can't get your solution working. It gave me the idea to create a new
"normal" form (form2) and declare the variables on this form. Then load
form2 in form1 when form1 is loaded and showed. This solution works. Keep
wondering why declaring in frmMain generates the error.

Sjoerd



Don@home.com (23-07-2003)
Kommentar
Fra : Don@home.com


Dato : 23-07-03 21:29

On Wed, 23 Jul 2003 21:32:56 +0200, "sjoerd" <iwi@iwi.myweb.nl> wrote:

>
>"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
>news:ohvshvk1jgtihtm0u278gjtpskd7e2k0me@4ax.com...
>> "sjoerd" <iwi@iwi.myweb.nl>'s wild thoughts were released on
>> Wed, 23 Jul 2003 12:35:00 +0200 bearing the following fruit:
>>
>> >Hi,
>> >
>> >I have a problem in a MDI-project.
>> >I declared a variable MyVarAA in frmMain.frm (Public MyVarAA) in the
>General
>> >Declaration section)
>> >
>> >I need this variable in Form1, so in the Form_Load of this form I wrote:
>> >
>> >MyVarBB = frmMain.MyVarAA
>> >
>> >When trying to run the program I get the following error:
>> >
>> >Run-time error 426 (only one MDI-form allowed).
>> >
>> >The debug-information tells me:
>> >
>> >frmMain.MyVarAA = <object variable or with block variable not set>
>> >
>> >Acoording to the book I use (Using Visual Basic 6) is this the way to do
>it.
>> >Error in the Book? Bug in VB? Something else?
>> >
>> >Thanks,
>> >
>> >Sjoerd
>> >

First off I don't know why you want to do it this way BUT here's something to
look at...

In the MDIForm do:

Option Explicit
Public MyVarAA As MDIForm1 'Declare an Object Varible

Private Sub MDIForm_Load()
'Just declaring it is only half the process. Have to use the
'Set blah = blahblah to actually create the references..
Set MyVarAA = MDIForm1 'Set the references to This Form
End Sub

Then in Form1 (MDIChild form) do:

Option Explicit
Dim MyVarBB As MDIForm1 'Declare an Object Varible (early binding)

Private Sub Form_Load()
Set MyVarBB = MDIForm1.MyVarAA 'Set the References to that in MDIForm
'Now MyVarBB has all the references of MDIForm1
End Sub


Have a good day...

Don

Don@home.com (23-07-2003)
Kommentar
Fra : Don@home.com


Dato : 23-07-03 21:34

I forgot to mention the following::

In the MDI Child form you could also do:

Option Explicit
Dim MyVarBB As MDIForm1
Private Sub Form_Load()
Set MyVarBB = MDIForm1 'Not Using .MyVarAA it will be the same (kinda)
'In this case MyVarAA in the MDIForm is not needed at all...
MyVarBB.Command1.Visible = False
End Sub


On Wed, 23 Jul 2003 20:28:46 GMT, Don@home.com wrote:

>On Wed, 23 Jul 2003 21:32:56 +0200, "sjoerd" <iwi@iwi.myweb.nl> wrote:
>
>>
>>"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
>>news:ohvshvk1jgtihtm0u278gjtpskd7e2k0me@4ax.com...
>>> "sjoerd" <iwi@iwi.myweb.nl>'s wild thoughts were released on
>>> Wed, 23 Jul 2003 12:35:00 +0200 bearing the following fruit:
>>>
>>> >Hi,
>>> >
>>> >I have a problem in a MDI-project.
>>> >I declared a variable MyVarAA in frmMain.frm (Public MyVarAA) in the
>>General
>>> >Declaration section)
>>> >
>>> >I need this variable in Form1, so in the Form_Load of this form I wrote:
>>> >
>>> >MyVarBB = frmMain.MyVarAA
>>> >
>>> >When trying to run the program I get the following error:
>>> >
>>> >Run-time error 426 (only one MDI-form allowed).
>>> >
>>> >The debug-information tells me:
>>> >
>>> >frmMain.MyVarAA = <object variable or with block variable not set>
>>> >
>>> >Acoording to the book I use (Using Visual Basic 6) is this the way to do
>>it.
>>> >Error in the Book? Bug in VB? Something else?
>>> >
>>> >Thanks,
>>> >
>>> >Sjoerd
>>> >
>
>First off I don't know why you want to do it this way BUT here's something to
>look at...
>
>In the MDIForm do:
>
>Option Explicit
>Public MyVarAA As MDIForm1 'Declare an Object Varible
>
>Private Sub MDIForm_Load()
>'Just declaring it is only half the process. Have to use the
>'Set blah = blahblah to actually create the references..
>Set MyVarAA = MDIForm1 'Set the references to This Form
>End Sub
>
>Then in Form1 (MDIChild form) do:
>
>Option Explicit
>Dim MyVarBB As MDIForm1 'Declare an Object Varible (early binding)
>
>Private Sub Form_Load()
>Set MyVarBB = MDIForm1.MyVarAA 'Set the References to that in MDIForm
>'Now MyVarBB has all the references of MDIForm1
>End Sub
>
>
>Have a good day...
>
>Don

Have a good day...

Don

preben nielsen (24-07-2003)
Kommentar
Fra : preben nielsen


Dato : 24-07-03 06:05


"sjoerd" <iwi@iwi.myweb.nl> skrev i en meddelelse
news:bfmntj$g15$1@news1.tilbu1.nb.home.nl...

> Can't get your solution working. It gave me the idea to create a
new
> "normal" form (form2) and declare the variables on this form.

Why a form ? This is what a module is meant for !


--
/\ preben nielsen
\/\ prel@post.tele.dk



Jan Hyde (24-07-2003)
Kommentar
Fra : Jan Hyde


Dato : 24-07-03 09:38

"sjoerd" <iwi@iwi.myweb.nl>'s wild thoughts were released on
Wed, 23 Jul 2003 21:32:56 +0200 bearing the following fruit:

>
>"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
>news:ohvshvk1jgtihtm0u278gjtpskd7e2k0me@4ax.com...
>> "sjoerd" <iwi@iwi.myweb.nl>'s wild thoughts were released on
>> Wed, 23 Jul 2003 12:35:00 +0200 bearing the following fruit:
>>
>> >Hi,
>> >
>> >I have a problem in a MDI-project.
>> >I declared a variable MyVarAA in frmMain.frm (Public MyVarAA) in the
>General
>> >Declaration section)
>> >
>> >I need this variable in Form1, so in the Form_Load of this form I wrote:
>> >
>> >MyVarBB = frmMain.MyVarAA
>> >
>> >When trying to run the program I get the following error:
>> >
>> >Run-time error 426 (only one MDI-form allowed).
>> >
>> >The debug-information tells me:
>> >
>> >frmMain.MyVarAA = <object variable or with block variable not set>
>> >
>> >Acoording to the book I use (Using Visual Basic 6) is this the way to do
>it.
>> >Error in the Book? Bug in VB? Something else?
>> >
>> >Thanks,
>> >
>> >Sjoerd
>> >
>>
>>
>> Dim frm as frmMDIMain
>>
>> '-- Load an instance of the MDI form
>> set frm = New FrmMDIMain
>> frm.Show
>> '-- Causes another instance of the MDI to load
>> frmMDIMain.Caption = "Ooops"
>> '-- Does not cause another instance to load
>> frm.Caption = "Correct'
>>
>> J
>>
>>
>> --
>> So I said "Do you want a game of Darts?", he said "OK then", I said
>> "Nearest to bull starts". He said "Baa", I said "Moo", he said
>> "You're closest".
>>
>> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>>
>
>Can't get your solution working. It gave me the idea to create a new
>"normal" form (form2) and declare the variables on this form. Then load
>form2 in form1 when form1 is loaded and showed. This solution works. Keep
>wondering why declaring in frmMain generates the error.
>
>Sjoerd

That's because it's not a solution. It's a demonstration of
the problem. The solution I leave to you

J


--
A good pun is it’s own reword.

[Abolish the TV Licence - http://www.tvlicensing.biz/]


Søg
Reklame
Statistik
Spørgsmål : 177557
Tips : 31968
Nyheder : 719565
Indlæg : 6408879
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste