Attention: We are retiring the ASP.NET Community Blogs. Learn more >

A VB Language Bug or Feature?

Following on from post http://weblogs.asp.net/dneimke/archive/2004/04/22/117856.aspx ...

Another issue with this "feature" is that I'd almost class it as a bug in VB.NET that they don't handle the Null Terminator for you. For example:

    Dim a As String = "Foo"
    Dim b As String = CHR(0)
    Dim c As String = "Bar"
    MsgBox( a & b & c ) '    <== displays "Foo"

Whereas...

    Dim a As String = "Foo"
    Dim b As String = CHR(0)
    Dim c As String = "Bar"
    Console.WriteLine( a & b & c )    ' <== displays "FooBar" 

I'd call that inconsistent with my expectation as a language "user". So what would you call this? A VB Language Bug or Feature?

4 Comments

  • I'd call it a feature of the formatter of Console.Writeline. It isn't really a VB issue.

  • You should get the same results using any other .Net language.

  • I don't think it's a feature or a bug... it's simply the way different layers of the user interface present the information.



    Put simply, the behaviour in the MsgBox() function seems to have been valid for many years. This is expected behaviour, no matter how 'unusual' it is considered 'today'.



    Times change, but not all UI's do. :)

  • I guess it is due to function signatures. Prompt is of type Object and value of primitive type String:



    Public Function MsgBox(ByVal Prompt As Object, Optional ByVal Buttons As Microsoft.VisualBasic.MsgBoxStyle = 0, Optional ByVal Title As Object = Nothing) As Microsoft.VisualBasic.MsgBoxResult

    Member of: Microsoft.VisualBasic.Interaction



    Public Shared Sub WriteLine(ByVal value As String)

    Member of: System.Console

Comments have been disabled for this content.