Create a subroutine in VB6

0

I'm trying to create a subroutine that can read the entire alphabet from A to Z and save / display letters read in duplicate (AA, BB, CC, ...) in VB6 but it still did not work.

My attempt:

Do  while alfa <> z
    alfa = alfa + a
    lstalfabeto.additem alfa
Loop
    
asked by anonymous 28.05.2014 / 09:40

1 answer

1

Assuming you have a collection with the letters you want to duplicate, one way to write the subroutine will be:

Private Sub CommandButton1_Click()

    Dim alfabeto As New Collection

    ' Colecção que vai receber o alfabeto duplicado
    Dim alfabetoDuplicado As New Collection

   'Fora do escopo da pergunta mas preencher um array com o alfabeto para clareza
    For Index = 65 To 90
        alfabeto.Add Chr(Index)
    Next

    For t = 1 To alfabeto.Count
        alfabetoDuplicado.Add (alfabeto(t) + alfabeto(t))
    Next

End Sub
    
28.05.2014 / 11:05