Imports System.IO Public Class mainform Public ac As Double Public ch As Double Private Sub mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub 'open file Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click Dim filereader As StreamReader Dim result As DialogResult result = OpenFileDialog1.ShowDialog If result = DialogResult.OK Then filereader = New StreamReader(OpenFileDialog1.FileName) Txtcount.Text = filereader.ReadToEnd filereader.Close() End If End Sub 'word counter by counting the spaces Private Sub TheNumberOfWordsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TheNumberOfWordsToolStripMenuItem.Click txtnmb.Text = "" If Txtcount.Text = "" Then MsgBox("Please open a text file first !!!") Exit Sub End If Dim number() As String ac = 0 ch = 0 number = Txtcount.Text.Split(" ") 'txtnmb.Text = "" For i = 0 To (number.Length - 2) ac = ac+ 1 Next txtnmb.Text = txtnmb.Text & Val(ac) & vbTab End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)