2009年4月24日 星期五

宇數統計

image

'宇數統計
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim rStr = ""
        Dim s = "Where there is a will, there is a way."
        Dim lineArray() = Split(s, " ")
        rStr = "Word:" & lineArray.Length & vbNewLine

        Dim c = 0
        Dim cb = 0
        Dim i = 1
        While Mid(s, i, 1) <> ""
            If Mid(s, i, 1) <> " " Then
                c = c + 1
            Else
                cb = cb + 1
            End If
            i = i + 1
        End While
        rStr = rStr & "character:" & c & Space(3) & "blank:" & cb
        MsgBox(rStr)
    End Sub
End Class

沒有留言:

張貼留言