ShehzadMunir
asked on
How to Unload the Label Control
Situation is that there is a form on which I select the Invoice No. FOr that Invoice No, there exists multiple Referance No in the database. Whenever user selects the Invoice No I display the Related Referance No by using the lable control array as follows:
'------------------------- ---------- ---------- ---------
'This procedure accepts a parameter named strValue
'Which is the value to be displayed in the caption
'of the label control array
'------------------------- ---------- ---------- ---------
Private Sub AddControlsAtRunTime(strVa lue As String)
Dim I As Integer
I = Me.lblReferenceNo.UBound
If I = 0 And Trim(Me.lblReferenceNo(I). Caption) = "0" Then
Me.lblReferenceNo(I).Capti on = Trim(strValue)
Else
Load Me.lblReferenceNo(I + 1)
Me.lblReferenceNo(I + 1).Visible = True
Me.lblReferenceNo(I + 1).Caption = Trim(strValue)
Me.lblReferenceNo(I + 1).Top = Me.lblReferenceNo(I).Top + Me.lblReferenceNo(I).Heigh t '+ 60
Me.lblReferenceNo(I + 1).Left = Me.lblReferenceNo(I).Left
End If
End Sub
'------------------------- ---------- ---------- -----
'------------------------- ---------- ---------- ----
But when I need to change the Invoice No then I need to initialixe the label control array, i.e I would need to unload the label controls created at run by using the following procedure
'------------------------- ---------- ---------- -
Private Sub RemoveControlsAtRunTime()
Dim I As Integer
Dim J As Integer
I = Me.lblReferenceNo.UBound
If I > 0 Then
For J = I To 1 Step -1
Unload lblReferenceNo(J)
Next J
End If
End Sub
'------------------------- ---------- ---------
But in this procedure the statment
"Unload lblReferenceNo(J)"
gives me an error
Run time error '365'
Unable to unload witrhin this context.
So while unloading I come across this error.
Can any body tell me about this arror.
'-------------------------
'This procedure accepts a parameter named strValue
'Which is the value to be displayed in the caption
'of the label control array
'-------------------------
Private Sub AddControlsAtRunTime(strVa
Dim I As Integer
I = Me.lblReferenceNo.UBound
If I = 0 And Trim(Me.lblReferenceNo(I).
Me.lblReferenceNo(I).Capti
Else
Load Me.lblReferenceNo(I + 1)
Me.lblReferenceNo(I + 1).Visible = True
Me.lblReferenceNo(I + 1).Caption = Trim(strValue)
Me.lblReferenceNo(I + 1).Top = Me.lblReferenceNo(I).Top + Me.lblReferenceNo(I).Heigh
Me.lblReferenceNo(I + 1).Left = Me.lblReferenceNo(I).Left
End If
End Sub
'-------------------------
'-------------------------
But when I need to change the Invoice No then I need to initialixe the label control array, i.e I would need to unload the label controls created at run by using the following procedure
'-------------------------
Private Sub RemoveControlsAtRunTime()
Dim I As Integer
Dim J As Integer
I = Me.lblReferenceNo.UBound
If I > 0 Then
For J = I To 1 Step -1
Unload lblReferenceNo(J)
Next J
End If
End Sub
'-------------------------
But in this procedure the statment
"Unload lblReferenceNo(J)"
gives me an error
Run time error '365'
Unable to unload witrhin this context.
So while unloading I come across this error.
Can any body tell me about this arror.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DO NOT ACCEPT THIS COMMENT AS AN ANSWER. If you have further comments on this question or the recommendation, please leave them here.
ShehzadMunir,
Some of these questions have been open for some time. Please resolve them appropriately as soon as possible.
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20090669
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20100224
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20137180
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20154981
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20230974
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20239948
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20243913
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20193587
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20184112
Thanks,
Netminder
Community Support Moderator
Experts Exchange