I've having trouble with the code below. A user will enter a line of text, and the text will then be saved in an array. The first character of the text is saved, and then used in a For Each loop to determine how many times that character appears in the text. When I execute this code, I get blanks in the array instead of the text. Does anyone see anything wrong with my code?
Thanks, Donna
Sub Main()
Dim textArray As Char() = New Char(79) {}
Dim savechar As Char
Dim intCount As Integer
Console.WriteLine("Enter a Line of Text")
Console.ReadLine().ToCharArray()
savechar = textArray(0)
Console.WriteLine(textArray)
For Each savechar In textArray
intCount += 1
Next
Console.WriteLine(savechar & " occurs " & intCount & " times.")
End Sub
Thanks, Donna
Sub Main()
Dim textArray As Char() = New Char(79) {}
Dim savechar As Char
Dim intCount As Integer
Console.WriteLine("Enter a Line of Text")
Console.ReadLine().ToCharArray()
savechar = textArray(0)
Console.WriteLine(textArray)
For Each savechar In textArray
intCount += 1
Next
Console.WriteLine(savechar & " occurs " & intCount & " times.")
End Sub