I would like to discover and use the VB.Net equivalent to replace the VbNull
value seen in VB6, but I can't find the proper value that represents that null value.
Dim formatProvider As NumberFormatInfo =
DirectCast(CultureInfo.GetCultureInfo("es-ES").NumberFormat.Clone, NumberFormatInfo)
With formatProvider
.NumberDecimalSeparator = Microsoft.VisualBasic.vbNull
End With
Dim pi As String = Math.PI.ToString(String.Empty, formatProvider)
The NumberDecimalSeparator
property does not accepts an empty value, but it accpets the vbNull
value as well and it works perfectlly (the separator is removed), so... I suppose that I can reproduce the same result using the .Net Class library to avoid resort at VB6 things.
I've tried to replace the vbNull
with those other values, but all give an exception due to the emptiness restriction of the property that I mentioned above:
""
String.Empty
ControlChars.NullChar()
DBNull.Value.ToString
Nothing
UPDATE
I also tried these supposed solutions, any of these throws an exception of empty value but instead that it does not give me the expected result because using this as a separator to format a decimal number the number is printed broken.
Convert.ToChar(0)
Char.ConvertFromUtf32(0)
New String(Char.ConvertFromUtf32(0))
Source: VB.NET - string of nulls
vbnull is a datatype and not what you think it is. From Object Viewer (VB6 or Office VBA Editor press F2)
Things you may have it confused with
Trigger is correct vbNull is a constant, but its value is defined thusly:
Public Const vbNull As VariantType = VariantType.Null
Please see Microsoft Reference Source