conscript Posted October 29, 2006 at 10:48 PM Report Share #60865 Posted October 29, 2006 at 10:48 PM E' o seguinte, tenho um programa em que quero guardar informação sobre varios carros, listar essa informação, remover um carro, adicionar. Para isso tenho Dim CarroLista As New ArrayList Dim carro(20) As Stand No stand tenho as propriades do carro, matricula, modelo.. etc. Agora e' o seguinte, para listar os carros estou a ir a cada posição da minha lista carro, mas para remover so' estou a remover da minha arraylist assim: WriteLine("Insira a matricula do carro a remover") Dim mtricula As String = ReadLine() For i As Integer = 0 To CarroLista.Count - 1 Dim car As Stand car = DirectCast(carro(i), Stand) If car.matricula = mtricula Then CarroLista.RemoveAt(i) WriteLine("Feito") End If Next Agora o problema e' que ao lista estou a listar assim: For i As Integer = 0 To carro.GetUpperBound(0) - 1 If Not (carro(i) Is Nothing) Then WriteLine("Matricula; {0}, Nome do Proprietario; {1}, Marca; {2}, modelo; {3}", carro(i).Matricula, carro(i).NomeP, carro(i).Marca, carro(i).Modelo) End If Next Ou seja eu listo o que esta na minha lista CARRO, e removo o que esta na minha arraylist o q eu vai dar que mesmo removendo ele vai listar a mesma. Agora nao sei como remover na lista tambem, ou entao listar antes a partir do arraylist.. so' nao sei como o fazer. Se alguem me poder ajudar, agradecia. Link to comment Share on other sites More sharing options...
Asgorath Posted January 4, 2007 at 10:58 AM Report Share #74378 Posted January 4, 2007 at 10:58 AM Boas Todos os ArrayList tem o método .Remove() "The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod Link to comment Share on other sites More sharing options...
Carloz Posted January 5, 2007 at 10:35 PM Report Share #74675 Posted January 5, 2007 at 10:35 PM Penso que tambem podes usar apenas List's em vez de ArrayList's. Tens todas as funçoes necessarias para verificar se existe (.contains), adicionar, (.add), remover (.remove), apagar (.clear), e por ai fora... "Rejoice not against me, O mine enemy: when I fall, I shall arise; when I sit in darkness, the LORD shall be a light unto me." - Micah 7:8 (KJV) Link to comment Share on other sites More sharing options...
Guest id194 Posted January 5, 2007 at 10:59 PM Report Share #74689 Posted January 5, 2007 at 10:59 PM Acho completamente desnecessario usares 2 arrays diferentes onde ambos têm o mesmo conteudo e os usas apra diferentes acções. Podes muito bem usar apenas um deles e para o que tu queres fazer, recomendo-te o ArrayList. Para listares a partir do ArrayList, nada como ler a documentação oficial: http://msdn2.microsoft.com/en-us/library/system.collections.arraylist.aspx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now