Vídeo recomendado
https://youtu.be/diWPPPhW-9E

CODIGO PARA DELETAR LINHA LISTBOX

Fórum para dúvidas sobre os fundamentos da linguagem de programação Visual Basic no contexto do VBA
itamar
Acabou de chegar
Acabou de chegar
Mensagens: 6
Registrado em: Seg Mai 03, 2021 5:47 pm

CODIGO PARA DELETAR LINHA LISTBOX

Mensagem por itamar »

OLA A TODOS
SOU CURIOSO NO RAMO DE VBA, CONSTRUÍ UMA PLANILHA PARA CONTROLE DE ESTOQUE ONDE TRABALHO (PARA USO PESSOAL)
PRECISO DE UM CÓDIGO PARA DELETAR UMA LINHA CARREGADO EM UMA LISTBOX.

SE FOR POSSÍVEL POSTO A PLANILHA AQUI!!
SE ALGUÉM PUDER AJUDAR.
Anexos
PESQUISA.png
PESQUISA.png (90.57 KiB) Exibido 3464 vezes


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Avatar do usuário
Reinaldo
Jedi
Jedi
Mensagens: 1537
Registrado em: Sex Ago 01, 2014 4:09 pm
Localização: Garça - SP / SCS - SP

Re: CODIGO PARA DELETAR LINHA LISTBOX

Mensagem por Reinaldo »

Poderia se algo +/- assim

Código: Selecionar todos

Private Sub CommandButton1_Click()
     Dim i As Integer
    With Me
        For i = 0 To .ListBox1.ListCount - 1
            If .ListBox1.Selected(i) Then
                resposta = MsgBox("Deseja excluir o item: " & .ListBox1.List(i) & "?", vbYesNo + vbQuestion, "Excluir?")
                If vbYes Then .ListBox1.RemoveItem (i)
            End If
        Next i
    End With
End Sub
mais detalhes^:
https://pt.stackoverflow.com/questions/ ... de-listbox
Caso não atenda, forneça maiores detalhes/exemplo/model


itamar
Acabou de chegar
Acabou de chegar
Mensagens: 6
Registrado em: Seg Mai 03, 2021 5:47 pm

Re: CODIGO PARA DELETAR LINHA LISTBOX

Mensagem por itamar »

DA ESSE ERRO AGORA... NESSA LINHA.
ERRO.png
ERRO.png (150.29 KiB) Exibido 3455 vezes
ListBox1.RemoveItem (i)


Avatar do usuário
Reinaldo
Jedi
Jedi
Mensagens: 1537
Registrado em: Sex Ago 01, 2014 4:09 pm
Localização: Garça - SP / SCS - SP

Re: CODIGO PARA DELETAR LINHA LISTBOX

Mensagem por Reinaldo »

Como disse anteriormente:
Caso não atenda, forneça maiores detalhes/exemplo/model


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


itamar
Acabou de chegar
Acabou de chegar
Mensagens: 6
Registrado em: Seg Mai 03, 2021 5:47 pm

Re: CODIGO PARA DELETAR LINHA LISTBOX

Mensagem por itamar »

Segue anexo da Planilha, caso precise de alguma senha 1234.
Dependendo da situação vou desistir dela .

Grato.
Anexos
Planilha de controle Estoque.rar
(131.19 KiB) Baixado 192 vezes


Avatar do usuário
Reinaldo
Jedi
Jedi
Mensagens: 1537
Registrado em: Sex Ago 01, 2014 4:09 pm
Localização: Garça - SP / SCS - SP

Re: CODIGO PARA DELETAR LINHA LISTBOX

Mensagem por Reinaldo »

Como seu listbox é "carregado" por RowSource; para excluir a linha e preciso excluir essa linha da planilha;
pois o listbox espelha os dados dela.
Para utilizar o metodo RemoveItem, sua listbox deve se povoada utilizando método AddItem


itamar
Acabou de chegar
Acabou de chegar
Mensagens: 6
Registrado em: Seg Mai 03, 2021 5:47 pm

Re: CODIGO PARA DELETAR LINHA LISTBOX

Mensagem por itamar »

Obrigado pela Atenção.


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Responder