Thursday, November 11, 2010

Thursday, November 11 2010

Here is a short program I wrote, one button will transfer text from your clipboard, and the other button will count how many words you have.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Clipboard.GetDataObject.GetDataPresent(DataFormats.Text) Then
Me.RichTextBox1.Paste()
RichTextBox1.Text = RichTextBox1.Text & vbCrLf



End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim counter As Integer = 0
Dim bigString As String = RichTextBox1.Text
Dim textChar As Char
Dim test As Char
Dim wordCounter = 0

For counter = 0 To bigString.Length - 1
textChar = bigString.Chars(counter)
If textChar = " " Then
wordCounter += 1

End If
Next
MessageBox.Show("There are " & wordCounter & " words.")
End Sub

No comments: