Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quicker way to fill an array 1

Status
Not open for further replies.

Paladyr

Programmer
Apr 22, 2001
508
US
Here is the code I have:

Code:
  Dim strLet(30) As String
  Dim intCount As Integer
  Dim intLet As Integer
  
  strLet(0) = "A"
  strLet(1) = "B"
  strLet(2) = "C"
  strLet(3) = "D"
  strLet(4) = "E"
  strLet(5) = "F"
  strLet(6) = "G"
  strLet(7) = "H"
  strLet(8) = "I"
  strLet(9) = "J"
  strLet(10) = "K"
  strLet(11) = "L"
  strLet(12) = "M"
  strLet(13) = "N"
  strLet(14) = "O"
  strLet(15) = "P"
  strLet(16) = "Q"
  strLet(17) = "R"
  strLet(18) = "S"
  strLet(19) = "T"
  strLet(20) = "U"
  strLet(21) = "V"
  strLet(22) = "W"
  strLet(23) = "X"
  strLet(24) = "Y"
  strLet(25) = "Z"
  strLet(26) = "AA"
  strLet(27) = "AB"
  strLet(28) = "AC"
  strLet(29) = "AD"
[\code]

Isn't there a way to say something like strLet = {"A", "B", "C"}???  I tried a couple things and nothing worked.  Thanks in advance!
 
Try

strLet = Array("A", "B", "C") ETC

should be okay I dont want to go to Chelsea!!!
 
I tried this:

strLet = Array("A", "B", "C", "D", "E", "F") etc... and it said "Compile error, can't assign to array" Any ideas? I am declaring strLet as strLet(200).
 
have you taken out the Dim strLet as String statement as well or changed it to as Array? I dont want to go to Chelsea!!!
 
It doesn't give me the option of declaring strLet as Array. I thought the way I was doing it was how you declare an array????
 
You can also use the Chr() function.
Code:
Dim strLet(30) As String
Dim i As Integer, j As Integer

For i = 0 to 29  
    j = i + 65
    If j < 91 Then
        strLet(i) = Chr(j)
    Else
        j = j - 26
        strLet(i) = Chr(65) & Chr(j)
    End If
Next i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top