HLRosenberger
asked on
Help with VB code
How can I easily do the following: for any string of 2 letters, for example, ag, dm, ou, etc., I want to generate a string that contains all letters of the alphabet between the 2 letters, inclusive. And also verify that the first letter precedes the second letter, alphabetically.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Version to create an output string
Question: does case matter in other words can you have a string "Ag"
If so do you need to preserve the case?
If not you can do this
Question: does case matter in other words can you have a string "Ag"
If so do you need to preserve the case?
If not you can do this
Sub Main()
Dim inp As String = "Ag"
Dim otp As String
inp = inp.ToLower()
If inp.Length = 2 And inp.Chars(0) < inp.Chars(1) Then
Dim i As Integer
For i = Asc(inp.Chars(0)) To Asc(inp.Chars(1))
otp = otp & Chr(i)
Next
End If
Console.WriteLine(otp)
End Sub
ASKER
thanks.
Open in new window