VB.Net中的VB6的vbNull是否等效? [英] VB6's vbNull equivalent in VB.Net?
问题描述
我想发现和使用等效的VB.Net来替换VB6中出现的 VbNull
值,但是我找不到代表该空值的正确值.
Dim formatProvider为NumberFormatInfo =DirectCast(CultureInfo.GetCultureInfo("es-ES").NumberFormat.Clone,NumberFormatInfo)与formatProvider.NumberDecimalSeparator = Microsoft.VisualBasic.vbNull结束于Dim pi As String = Math.PI.ToString(String.Empty,formatProvider)
NumberDecimalSeparator
属性不接受空值,但它也接受 vbNull
值,并且可以完美地工作(删除了分隔符),所以...我想我可以使用.Net类库重现相同的结果,从而避免诉诸于VB6.
我试图用其他值替换 vbNull
,但是由于上面提到的属性的空性限制,所有这些都给出了例外:
"空字符串ControlChars.NullChar()DBNull.Value.ToString没有什么
更新
我也尝试了这些假定的解决方案,其中任何一个都抛出一个空值异常,但它没有给我预期的结果,因为使用它作为分隔符来格式化十进制数字时,数字被打断了.
Convert.ToChar(0)Char.ConvertFromUtf32(0)新字符串(Char.ConvertFromUtf32(0))
来源: VB.NET-空字符串
触发器是正确的vbNull是一个常数,但是其值因此定义为:公共常量vbNull As VariantType = VariantType.Null
>
请参阅 Microsoft参考源
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
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
这篇关于VB.Net中的VB6的vbNull是否等效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!