Postada em 14/06/2009 19:28 hs
Criei conforme abaixo dentro de um Frame. Preciso antes da rotina deletar os controles TextBox exitentes, pois se eu aciona-la novamente da erro dizendo que os controles ja existem. resumindo, preciso limpar o Frame totalmente. No VBA funcionava diferente e eu tinha a opção: (Frame2.Controls.Clear), já no VB não existe o Clear. Alguma sugestão?
Private Sub IncluirItems1()
Dim Referencia As Integer Dim Pos Dim ID As Long Dim PosicaoLtd As Long Dim L Dim PosLeft, PosTop Dim Box(0 To 10) As Object
If Trim(TxtBuscaLM.text) = "" Then MsgBox "Entre com o nº de LM!", vbOKOnly, "Lista de Material" TxtBuscaLM.SetFocus Exit Sub End If
Set Tabela_LM = New ADODB.Recordset If Tabela_LM.State = 1 Then Tabela_LM.Close
With Tabela_LM .CursorType = adOpenStatic .CursorLocation = adUseClient .LockType = adLockReadOnly .Source = "SELECT Dispositivo,Codigo,Obra,Fabrica,Recebido,Descricao,Origem,Destino FROM Dados WHERE LM_1 = '" & TxtBuscaLM.text & "' and Dispositivo = '003' and Codigo <> 'CANCEL' and Codigo <> 'RETIRADO' and Codigo > '0'" .ActiveConnection = Banco2 .Open Frame2.Visible = False If .EOF Then Else .MoveMax PosicaoLtd = .RecordCount .MoveMin For L = 0 To PosicaoLtd - 1 PosLeft = 1 If Referencia = 1 Then PosTop = Pos + 1 End If Text1 = PosicaoLtd - 1 Frame2.Height = (315 + 20) * L 'Frame2.Height = Frame2.Height + PosTop * L Set Box(0) = Controls.Add("VB.TextBox", "A" & L + 1, Frame2) Box(0).Move PosLeft + 8, (315 + 20) * L + 20, 576, 315 Box(0).Tag = "X" Box(0).Appearance = 0 Box(0).BorderStyle = 1 Box(0).Visible = True Box(0).FontSize = 11 Box(0).Alignment = 2 Dim C For C = 0 To L Box(0) = C + 1 Next C Set Box(1) = Controls.Add("VB.TextBox", "B" & L + 1, Frame2) Box(1).Move PosLeft + 600, (315 + 20) * L + 20, 950, 315 Box(1).Tag = "X" Box(1).Appearance = 0 Box(1).BorderStyle = 1 Box(1).Visible = True Box(1).FontSize = 11 Box(1).Alignment = 2 Box(1).text = "LM" & "-" & TxtBuscaLM.text Set Box(2) = Controls.Add("VB.TextBox", "C" & L + 1, Frame2) Box(2).Move PosLeft + 1560, (315 + 20) * L + 20, 1180, 315 Box(2).Tag = "X" Box(2).Appearance = 0 Box(2).BorderStyle = 1 Box(2).Visible = True Box(2).FontSize = 11 Box(2).Alignment = 2 Box(2).text = Nnull(Tabela_LM!Codigo) Set Box(3) = Controls.Add("VB.TextBox", "D" & L + 1, Frame2) Box(3).Move PosLeft + 2760, (315 + 20) * L + 20, 710, 315 Box(3).Tag = "X" Box(3).Appearance = 0 Box(3).BorderStyle = 1 Box(3).Visible = True Box(3).FontSize = 11 Box(3).Alignment = 2 Box(3).text = Nnull(Tabela_LM!Dispositivo) Set Box(4) = Controls.Add("VB.TextBox", "E" & L + 1, Frame2) Box(4).Move PosLeft + 3480, (315 + 20) * L + 20, 5750, 315 Box(4).Tag = "X" Box(4).Appearance = 0 Box(4).BorderStyle = 1 Box(4).Visible = True Box(4).FontSize = 11 Box(4).Alignment = 0 Box(4).text = Nnull(Tabela_LM!Descricao) Set Box(5) = Controls.Add("VB.TextBox", "F" & L + 1, Frame2) Box(5).Move PosLeft + 9240, (315 + 20) * L + 20, 1060, 315 Box(5).Tag = "X" Box(5).Appearance = 0 Box(5).BorderStyle = 1 Box(5).Visible = True Box(5).FontSize = 11 Box(5).Alignment = 2 Box(5).text = Nnull(Tabela_LM!Recebido) Set Box(6) = Controls.Add("VB.TextBox", "G" & L + 1, Frame2) Box(6).Move PosLeft + 10320, (315 + 20) * L + 20, 950, 315 Box(6).Tag = "X" Box(6).Appearance = 0 Box(6).BorderStyle = 1 Box(6).Visible = True Box(6).FontSize = 11 Box(6).Alignment = 2 If Tabela_LM!Obra = 0 Or Tabela_LM!Obra = Empty Then Box(6).text = Nnull(Tabela_LM!Fabrica) ElseIf Tabela_LM!Fabrica = 0 Or Tabela_LM!Fabrica = Empty Then Box(6).text = Nnull(Tabela_LM!Obra) End If Set Box(7) = Controls.Add("VB.TextBox", "H" & L + 1, Frame2) Box(7).Move PosLeft + 11280, (315 + 20) * L + 20, 950, 315 Box(7).Tag = "X" Box(7).Appearance = 0 Box(7).BorderStyle = 1 Box(7).Visible = True Box(7).FontSize = 11 Box(7).Alignment = 2 Box(7).text = Nnull(Tabela_LM!Origem) Set Box(8) = Controls.Add("VB.TextBox", "I" & L + 1, Frame2) Box(8).Move PosLeft + 12240, (315 + 20) * L + 20, 960, 315 Box(8).Tag = "X" Box(8).Appearance = 0 Box(8).BorderStyle = 1 Box(8).Visible = True Box(8).FontSize = 11 Box(8).Alignment = 2 Box(8).text = Nnull(Tabela_LM!Destino) .MoveNext Next End If Frame2.Visible = True End With
Pos = Pos + 20 ID = ID + 1 End Sub
|