Results 1 to 2 of 2

Thread: Checking blank spaces

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    283

    Checking blank spaces

    Can anyone tell me how to check blank spaces. For example I am trying to check whether or not there is a blank space in an Excel cell. The blank space could be in the following form
    no space = ""
    one space = " "
    two space = " "
    and so on. ... There could be more combination.

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Checking blank spaces

    Try this one
    vb Code:
    1. Private Function isSpaceExist(ByVal stext As String) As Integer
    2.         Dim npos As Integer = 0
    3.         Dim ncount() As String
    4.         npos = stext.IndexOf(" ") 'if a space is found
    5.         If npos Then
    6.             ncount = stext.Split(" ") 'split with respect to space
    7.             'Print the number of spaces
    8.             Console.WriteLine("No of space found: " & ncount.Length.ToString)
    9.         End If
    10.         Return ncount.Length
    11.     End Function
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width