Toon posts:

[VB6] Error 365 unable to unload

Pagina: 1
Acties:

Verwijderd

Topicstarter
Hallo,

Ik probeer controls uit een control array te unloaden, die ik eerder tijdens run-time geload heb, maar dat lukt niet. Ik krijg error 365 "Unable to unload within this context".
Control(0) probeer ik niet te unloaden, die heb ik tijdens design-time gemaakt.

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Private Sub LoadShowFieldControls(pFields As ADODB.Fields)

Dim c As Integer
For c = 1 To chkShow1.count - 1
 Unload chkShow1(c)
Next c

For c = 0 To pFields.count - 1
    If c = 0 Then
        chkShow1(c).Caption = pFields.Item(c).Name
    Else
        Load chkShow1(c)
        chkShow1(c).Visible = True
        chkShow1(c).Top = chkShow1(0).Top + 500
        chkShow1(c).Caption = pFields.Item(c).Name
    End If
Next c

CleanUp:
End Sub


Als er geen andere oplossing is, moet ik maar gewoon de bestaande controls behouden, en de egenschappen veranderen. Als het er tevel zijn, moet ik ze dan maar invisible maken. Maar mooi programmeerwerk vind ik dat niet.

Bedankt voor jullie hulp,

Wilde_Bill

  • OZ-Gump
  • Registratie: November 2002
  • Laatst online: 14-05-2024

OZ-Gump

terug van weggeweest

't is vroeg, dus don't shoot me als het niet klopt. Maar is count van de controls niet gelijk aan het aantal, en dus 1 t/m count? Want normaal gezien doe je dit:
Visual Basic:
1
for i = 0 to count -1
Het lijkt me dus dat jij in jouw geval, omdat je het eerste item (item o) niet wilt unloaden, het volgende zou moeten doen:

Visual Basic:
1
for i = 1 to count -2

My personal website


Verwijderd

Topicstarter
Ehm, nee dat zou inhouden dat ik ook de laatste niet zou unloaden.

toch dank,

Wilde_bill

  • Shadowman
  • Registratie: Januari 2002
  • Niet online
OZ-Gump schreef op 22 mei 2004 @ 09:43:
't is vroeg, dus don't shoot me als het niet klopt. Maar is count van de controls niet gelijk aan het aantal, en dus 1 t/m count?
de count van de controls is wel het aantal controls dat aanwezig zijn. Er wordt alleen geteld vanaf 0 en bij die count vanaf 1.
Want normaal gezien doe je dit:
Visual Basic:
1
for i = 0 to count -1
Het lijkt me dus dat jij in jouw geval, omdat je het eerste item (item o) niet wilt unloaden, het volgende zou moeten doen:

Visual Basic:
1
for i = 1 to count -2
Visual Basic:
1
for i = 1 to count -1
Is logischer als de laatste wel aanwezig moet zijn :).

Verwijderd

Topicstarter
jemig, MSDN heeft ook soms vreemde manieren om je zaken te laten weten. Hier is wat informatie, die je alleen krijgt als je op help klikt bij de foutmelding...

Blijkbaar mag bij de meeste events geen unload statement gebruiken... }:O
Ik denk trouwens dat het handiger is om de controls van achteren naar voren te unloaden dus met
code:
1
2
3
For c = 1 To chkShow1.count - 1
 Unload chkShow1(chkShow1.count - c)
Next c

in plaats van
code:
1
2
3
For c = 1 To chkShow1.count - 1
 Unload chkShow1(c)
Next c


Maar goed, het mag allemaal niet baten.
Misschien even pauzeren, voordat ik vanuit mijn combobox_click event de sub aanroep....
Weet iemand hoe dat moet, en of het helpt? :?

Anders maar de eerstgenoemde oplossing, gewoon onzichtbaar maken.


'-----------------------------------------
In some situations you are not allowed to unload a form or a control on a form. This error has the following causes and solutions:

There is an Unload statement in the Paint event for the form or for a control on the form that has the Paint event.
Remove the Unload statement from the Paint event.

There is an Unload statement in the Change, Click, or DropDown events of a ComboBox.
Remove the Unload statement from the event.

There is an Unload statement in the Scroll event of an HScrollBar or VScrollBar control.
Remove the Unload statement from the event.

There is an Unload statement in the Resize event of a Data, Form, MDIForm, or PictureBox control.
Remove the Unload statement from the event.

There is an Unload statement in the Resize event of an MDIForm that is trying to unload an MDI child form.
Remove the Unload statement from the event.

There is an Unload statement in the RePosition or Validate event of a Data control.
Remove the Unload statement from the event.

There is an Unload statement in the ObjectMove event of an OLE Container control.
Remove the Unload statement from the event.
'--------------------------------------

Verwijderd

Topicstarter
Nee, pauzeren of iets dergelijks gaat denk ik echt niet helpen.
Ik kan pas unloaden als de ComboBox_Click sub helemaal is ge-exit, dus alles dat ik vanuit daar aanroep, kan het ook niet.
Ik zou een of andere event kunnen kiezen om overvloedige controls achteraf te unloaden, maar dat wordt meer een detail.
Onzichbaar is dus maar het devies. Wel een beetje flauw allemaal, maarja, we leven ermee.

Dank voor hulp!

Wilde_Bill

  • mulder
  • Registratie: Augustus 2001
  • Laatst online: 17:00

mulder

ik spuug op het trottoir

For c = (chkShow1.count - 1) To 1 Step - 1

oogjes open, snaveltjes dicht

Pagina: 1