Ejercicio
Contar palabras
Objetivo
Crear un programa de Visual Basic para contar la cantidad de palabras almacenadas en un archivo de texto
Código
Imports System
Imports System.IO
Class Program
Private Shared Sub Main(ByVal args As String())
Dim file As StreamReader = File.OpenText("1.cs")
Dim line As String
Dim amountOfWords As Integer = 0
Do
line = file.ReadLine()
If line IsNot Nothing Then
Dim words As String() = line.Split(" "c)
amountOfWords += words.Length
End If
Loop While line IsNot Nothing
file.Close()
Console.WriteLine("Words: " & amountOfWords)
End Sub
End Class