Count Number of Words in a Sentence using ASP

There is no function in ASP to count number of words in sentence or long string. Bellow is very simple function that count number of words and return that count.

< %
Function CountWords (StrValue)
  Dim iWords, mLengthWithSpaces, mLengthWithoutSpaces

  ' following line calculate the actual length of string
  mLengthWithSpaces = Len(StrValue)

  ' following line remove all spaces from string and then calculate the length of string
  mLengthWithoutSpaces = Len(Replace(StrValue, " ", ""))

  ' subtract length (without spaces) from actual string length
  iWords = mLengthWithSpaces - mLengthWithoutSpaces

  CountWords = iWords + 1
End Function

'example
Msg = "This is text string"
Response.Write CountWords(Msg)

'output will be 4
%>

StretchBlt – Picture Stretching

The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary. Windows stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.

Declare Function StretchBlt Lib “gdi32″ Alias “StretchBlt” (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long [Read more...]