TS91 Posted December 16, 2009 at 10:26 PM Report Share #300923 Posted December 16, 2009 at 10:26 PM Boas, eu queria saber como posso copiar os items que estão numa listbox para uma array e depois meter os items pela a mesma ordem noutra listbox noutro form? Link to comment Share on other sites More sharing options...
ribeiro55 Posted December 16, 2009 at 11:00 PM Report Share #300933 Posted December 16, 2009 at 11:00 PM O truque está na linha em evidência. Dim LB1 As New ListBox Dim LB2 As New ListBox LB1.Items.Add("Olá") LB1.Items.Add("Olé") LB1.Items.Add("Olí") LB1.Items.Add("Oló") LB1.Items.Add("Olú") Dim TempArray() As String = Nothing For i As Integer = 0 To LB1.Items.Count - 1 ReDim Preserve TempArray(i) TempArray(i) = LB1.Items(i) Next For Each S As String In TempArray LB2.Items.Add(S) Next O estar noutro form, não implica nada muito mais especial. Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips" Link to comment Share on other sites More sharing options...
pmaster Posted December 17, 2009 at 10:24 PM Report Share #301196 Posted December 17, 2009 at 10:24 PM Boa noite malta Ribeiro55 queria perguntar te se me podias dizer se faz favor, porque usas-te: ReDim Preserve TempArray(i) Fiquei confuso. A intenção não era acrescentar mais um item ao array? Podias me explicar sff? B) Link to comment Share on other sites More sharing options...
anolsi Posted December 17, 2009 at 10:27 PM Report Share #301197 Posted December 17, 2009 at 10:27 PM É ir acrescentando posições ao array, mas mantendo os valores que já estão guardados. Se só colocasses Redim os dados eram anteriormente guardados no array eram apagados. "Nós somos o que fazemos repetidamente, a excelência não é um feito, e sim, um hábito."Não respondo a questões por PM que possam ser colocadas no fórum! Link to comment Share on other sites More sharing options...
ribeiro55 Posted December 17, 2009 at 10:52 PM Report Share #301202 Posted December 17, 2009 at 10:52 PM Nem mais. Como não podes prever o tamanho do array, vais "re-declarando" a variável, mas de forma a que não percas o que ela já armazena. Sérgio Ribeiro "Great coders aren't born. They're compiled and released""Expert coders do not need a keyboard. They just throw magnets at the RAM chips" Link to comment Share on other sites More sharing options...
pmaster Posted December 18, 2009 at 11:29 AM Report Share #301227 Posted December 18, 2009 at 11:29 AM Já percebi 😛 Muito obrigado 😛 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