a word
Imports System.IO
Dim dictionary As String = getFile() Dim words As New List(Of String) Using sr As New StreamReader(dictionary) While sr.Peek <> -1 Dim line As String = sr.ReadLine() If (Not line = Nothing And Not line = " ") Then If (line.Contains(" ")) Then Dim wordss As String() = line.Split(" ") For Each w As String In wordss words.Add(w) Next Else : words.Add(line) End If End If End While End Using
Private Function getFile() Dim fo As New OpenFileDialog() fo.Filter = "Text Files|*.txt" fo.FilterIndex = 1 fo.ShowDialog() Return fo.FileName End Function
Dim falseWords As New List(Of String) Dim falseNumbers As New List(Of Integer) Dim checkingWords As String() = TextBox1.Text.Split(" ") For i As Integer = 0 To checkingWords.Count() - 1 Dim isrealWord As Boolean = False For Each w As String In words If (checkingWords(i).ToLower() = w.ToLower()) Then isrealWord = True Next If Not (isrealWord) Then falseWords.Add(checkingWords(i)) falseNumbers.Add(i) End If Next For i As Integer = 0 To falseWords.Count() - 1 MsgBox("False Word at position " & falseNumbers(i) + 1 & ". Word: " & falseWords(i)) Next
Imports System.IO Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim falseWords As New List(Of String) Dim falseNumbers As New List(Of Integer) Dim dictionary As String = getFile() Dim words As New List(Of String) Using sr As New StreamReader(dictionary) While sr.Peek <> -1 Dim line As String = sr.ReadLine() If (Not line = Nothing And Not line = " ") Then If (line.Contains(" ")) Then Dim wordss As String() = line.Split(" ") For Each w As String In wordss words.Add(w) Next Else : words.Add(line) End If End If End While End Using Dim checkingWords As String() = TextBox1.Text.Split(" ") For i As Integer = 0 To checkingWords.Count() - 1 Dim isrealWord As Boolean = False For Each w As String In words If (checkingWords(i).ToLower() = w.ToLower()) Then isrealWord = True Next If Not (isrealWord) Then falseWords.Add(checkingWords(i)) falseNumbers.Add(i) End If Next For i As Integer = 0 To falseWords.Count() - 1 MsgBox("False Word at position " & falseNumbers(i) + 1 & ". Word: " & falseWords(i)) Next End Sub Private Function getFile() Dim fo As New OpenFileDialog() fo.Filter = "Text Files|*.txt" fo.FilterIndex = 1 fo.ShowDialog() Return fo.FileName End Function End Class