Docs: VB6 String Default value

Created on 18 May 2018  Â·  2Comments  Â·  Source: dotnet/docs

Hi everyone, I want to know if the VB6 String is nullable?. Please consider this
Dim TestStr As String
without assigning a value, what is the value of TestStr it is 'null' or empty ""?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Area - Visual Basic Guide

Most helpful comment

I don't remember, @jonathanlisoan, and I don't have a copy of VB6 available. Visual Basic .NET and VB 6.0 are very different products, My guess is that its default value is an empty string. But you should be able to tell with code something like the following:

Dim s As String
MsgBox(s Is Nothing)

It should either display True, in which case the default value of a string is Nothing, or False, in which case the default value of a string is "" or empty (which is probably most likely). If there's a compiler error, it's most likely because a string is not an object and therefore its value is an empty string.
I'm going to lose this issue, since this repository is for .NET-related issues. But feel free to respond if you need additional guidance.

All 2 comments

I don't know about VB6, but in VB.NET, which the documentation page you're looking at is about, String is a reference type, so its default value is Nothing (known as null in other languages).

I don't remember, @jonathanlisoan, and I don't have a copy of VB6 available. Visual Basic .NET and VB 6.0 are very different products, My guess is that its default value is an empty string. But you should be able to tell with code something like the following:

Dim s As String
MsgBox(s Is Nothing)

It should either display True, in which case the default value of a string is Nothing, or False, in which case the default value of a string is "" or empty (which is probably most likely). If there's a compiler error, it's most likely because a string is not an object and therefore its value is an empty string.
I'm going to lose this issue, since this repository is for .NET-related issues. But feel free to respond if you need additional guidance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tswett picture tswett  Â·  3Comments

sebagomez picture sebagomez  Â·  3Comments

stanuku picture stanuku  Â·  3Comments

mekomlusa picture mekomlusa  Â·  3Comments

FrancescoBonizzi picture FrancescoBonizzi  Â·  3Comments