Hi! I'm trying to make my program count the number of words in my text box by counting the number of spaces, I tried this:

VB Code:
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = 32 Then
  3. spacecount = spacecount + 1
  4. End If
  5. Label1.Caption = "Word Count:" & spacecount
  6. End Sub

but whenever I type a non space character, it seems that spacecount is reset to 0. Oh yeah, I know the algorithm of my program for counting words is very problematic, I'll fix that later.