Hi everyone!
(VS Community 2015)
I am trying to edit a word list (alphabetical order) text file encoded in UTF-8 (separated by enter/returns (one word per line)). The program's purpose is to remove any words with over 18 characters (>18, so 1-18 letters inclusive) and put the new list of text into a new text file.
The error message right now is:
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll. Additional information: Conversion from string "a" to type 'Integer' is not valid.
On this line:
Here is the full code:Code:If Len(Console.ReadLine(lines.Item(line))) > 18 Then
Thanks in advance.Code:Imports System.IO Public Class Form1 Dim strmRdr As New StreamReader("C:\Users\User\Documents\DictionaryReviser\DictionaryReviser\Resources\wordsEnutf8.txt") Dim lines As New List(Of String) Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load While strmRdr.Peek <> -1 lines.Add(strmRdr.ReadLine()) End While For line = 0 To (lines.Count) If Len(Console.ReadLine(lines.Item(line))) > 18 Then lines.RemoveAt(line) End If Next strmRdr.Close() strmRdr.Dispose() System.IO.File.WriteAllLines("C:\Users\User\Documents\DictionaryReviser\DictionaryReviser\Resources\dictionaryrevised.txt", lines) End Sub End Class




Reply With Quote
