.NET环境下如何实现VB6函数的模拟?
- 内容介绍
- 文章标签
- 相关推荐
本文共计336个文字,预计阅读时间需要2分钟。
String.Format函数在文档中被描述为VB6格式化函数的模拟函数。它源自Visual Basic命名空间,提供了兼容性,并基本上具有与String.Format相同的功能。实际上,这两种格式的日期和数字格式化功能相似。
String.Format函数在文档中称为VB6格式函数的模拟函数.还有来自VisualBasic命名空间的Format函数,它提供了兼容性,并且基本上具有与String.Format相同的功能.实际上,这两种格式的日期和数字.
但VB6的功能也能够格式化字符串:
? format$("hi there", ">") HI THERE ? format$("hI tHeRe", "<") hi there ? format$("hi there", ">!@@@... not @@@@@") HI ... not THERE
就我而言,String.Format无法做到这一点,也不是新格式.我也在兼容性格式文档中找不到任何提及VB6功能的某些部分丢失,似乎该功能被“默默地”弃用.
框架中是否有可以执行此类格式化的内容?
另一个要看的解决方案是使用Microsoft.VisualBasic.Compatibility.VB6命名空间,该命名空间包含几个向后兼容Visual Basic 6的类和方法.它主要用于升级工具,但它将为您节省麻烦.购买迁移工具或自己编写代码.MSDN文档:Support.Format Method (Microsoft.VisualBasic.Compatibility.VB6)
参数不会改变,它至少在您的示例中基本上支持相同的功能:
Imports Microsoft.VisualBasic.Compatibility.VB6 Console.WriteLine("HI THERE ") Console.WriteLine(Support.Format("hi there", ">")) Console.WriteLine("hi there ") Console.WriteLine(Support.Format("hI tHeRe", "<")) Console.WriteLine("HI ... not THERE") Console.WriteLine(Support.Format("hi there", ">!@@@... not @@@@@"))
本文共计336个文字,预计阅读时间需要2分钟。
String.Format函数在文档中被描述为VB6格式化函数的模拟函数。它源自Visual Basic命名空间,提供了兼容性,并基本上具有与String.Format相同的功能。实际上,这两种格式的日期和数字格式化功能相似。
String.Format函数在文档中称为VB6格式函数的模拟函数.还有来自VisualBasic命名空间的Format函数,它提供了兼容性,并且基本上具有与String.Format相同的功能.实际上,这两种格式的日期和数字.
但VB6的功能也能够格式化字符串:
? format$("hi there", ">") HI THERE ? format$("hI tHeRe", "<") hi there ? format$("hi there", ">!@@@... not @@@@@") HI ... not THERE
就我而言,String.Format无法做到这一点,也不是新格式.我也在兼容性格式文档中找不到任何提及VB6功能的某些部分丢失,似乎该功能被“默默地”弃用.
框架中是否有可以执行此类格式化的内容?
另一个要看的解决方案是使用Microsoft.VisualBasic.Compatibility.VB6命名空间,该命名空间包含几个向后兼容Visual Basic 6的类和方法.它主要用于升级工具,但它将为您节省麻烦.购买迁移工具或自己编写代码.MSDN文档:Support.Format Method (Microsoft.VisualBasic.Compatibility.VB6)
参数不会改变,它至少在您的示例中基本上支持相同的功能:
Imports Microsoft.VisualBasic.Compatibility.VB6 Console.WriteLine("HI THERE ") Console.WriteLine(Support.Format("hi there", ">")) Console.WriteLine("hi there ") Console.WriteLine(Support.Format("hI tHeRe", "<")) Console.WriteLine("HI ... not THERE") Console.WriteLine(Support.Format("hi there", ">!@@@... not @@@@@"))

