Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I iterate through the alphabet in Visual Basic?

Tags:

vb.net

I need to generate a loop that would iterate through each capital letter of the alphabet using Visual Basic (2008). What's the cleanest way to do this?

like image 459
Mark Meuer Avatar asked Mar 25 '11 16:03

Mark Meuer


People also ask

How do you iterate to A to Z?

While loop is used to print the alphabets from A to Z. A loop variable is taken to display of type 'char'. The loop variable 'i' is initialized with the first alphabet 'A' and incremented by 1 on every iteration. In the loop, the character 'i' is printed as the alphabet.


2 Answers

For Each c In "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()
...
Next
like image 93
manji Avatar answered Oct 20 '22 08:10

manji


The simplest way to do this would probably be:

For ascii = 65 To 90
    Debug.Print(Chr(ascii))
Next

I'm not really sure if it's the cleanest though. I haven't worked in vb.net much since I started with c#.

like image 17
asleepysamurai Avatar answered Oct 20 '22 07:10

asleepysamurai