How do i count the number of words in a textbox, then use that number to display on a label

Here we are just checking if there are two or more than 2 consecutive spaces are there, then only we need to remove that extra space.

But this program can fail in two cases,

  1. When there is only one space in string, that is string having only one character - space, but this issue can be resolved by trimming surrounding spaces.
  2. Second if there is space at the end of string, but that is already resolved in first case.

Might be some more dimensions to test the program code.

Thanks

1 Like

2 Likes