Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Sub Main()
- Dim file_name As String = "challenge9_list.txt"
- Dim f As New IO.StreamReader(file_name)
- Dim ch As Char
- Dim sumdigit As UInt16 = 0
- Dim alpha() As UInt16 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- While Not f.EndOfStream
- ch = f.ReadLine()(0)
- If Char.IsDigit(ch) Then
- sumdigit += Convert.ToInt16(ch)
- ElseIf Char.IsLetter(ch) Then
- alpha(Asc(ch) - Asc("a"c)) += 1
- End If
- End While
- Console.WriteLine("Sum = {0}", sumdigit)
- For i As UInt16 = 0 To alpha.Length - 1
- If alpha(i) <> 0 Then
- Console.WriteLine("'{0}' = {1}", Chr(i + Asc("a"c)), alpha(i))
- End If
- Next
- Console.ReadKey(True)
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment