locked
Checking for null RRS feed

  • Question

  • I am using visual basic 2008 express edition and am trying to check for a null character. The file I am using is a text file.

    It has some spaces (or null chars) in it and I am trying to remove them. If I edit the file and there are 5 spaces (or null) chars and I delete  one of them all will disappear.

    Any suggestions?

    Johnny


    John W. Wade

    Tuesday, October 9, 2012 8:50 PM

Answers

  • Try this

            Dim mychar As Char = vbNullChar
            If mychar = vbNullChar Then
                Console.Write("found a null character")
            End If


    jdweng

    Wednesday, October 10, 2012 12:51 AM

All replies

  • Try this

            Dim mychar As Char = vbNullChar
            If mychar = vbNullChar Then
                Console.Write("found a null character")
            End If


    jdweng

    Wednesday, October 10, 2012 12:51 AM
  • Does your file have spaces or does it have null characters, or both?  You say that when you edit the file and delete one of the spaces, they all disappear?  Or that is how you want it to behave?  Are you sure they are actually null characters and not spaces?  Also, you might have a tab character.  You might try looking at the file in a hex editor and see exactly what the characters are.
    Wednesday, October 17, 2012 10:31 PM