VB6格式功能:模拟在.NET [英] VB6 Format function: analog in .NET

查看:123
本文介绍了VB6格式功能:模拟在.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的String.Format 函数,称为文档作为模拟为格式从VB6功能。还有格式的VisualBasic 命名空间功能,提供了兼容的,基本上有同样的权力,的String.Format

There is String.Format function that is referred to in the documentation as the analog for Format function from VB6. There's also Format function from VisualBasic namespace that is provided for compatibility and basically has same powers as String.Format.

事实上,这两个格式的日期和数字。

Indeed, those two format dates and numbers.

不过,VB6的功能还能够格式化字符串:

But VB6's function was also able to format strings:

? format$("hi there", ">")
HI THERE
? format$("hI tHeRe", "<")
hi there
? format$("hi there", ">!@@@... not @@@@@")
HI ... not THERE

的String.Format 是不是能够做到这一点,就我而言,也不是新的格式。我也找不到任何提及在兼容性格式文档的VB6的某部分功能丧失,好像特点是去precated悄无声息。

String.Format is not able to do that, as far as I'm concerned, nor is the new Format. I also couldn't find any mention in the compatibility Format documentation that certain parts of VB6 functionality is lost, seems like the feature was deprecated "silently."

这有什么的框架,可以做到这一点类型的格式?

Is there anything in the framework that can do this type of formatting?

推荐答案

另一种解决方案来看看是用Microsoft.VisualBasic.Compatibility.VB6命名空间,其中包含几个类和方法是使用Visual Basic 6向后兼容。它主要是为了升级工具,而且可以节省您不必购买迁移工具或写code自己的麻烦。

Another solution to look at is to use the Microsoft.VisualBasic.Compatibility.VB6 namespace, which contains several classes and methods that are backwards compatible with Visual Basic 6. It's primarily meant for upgrade tools, but it will save you the hassle of having to purchase a migration tool or write the code yourself.

MSDN文档:<一href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.compatibility.vb6.support.format.aspx"相对=nofollow称号=Support.Format法(Microsoft.VisualBasic.Compatibility.VB6)> Support.Format方法(Microsoft.VisualBasic.Compatibility.VB6)

的参数不改变,它基本上支持相同的功能的至少给定的例子:

The parameters don't change and it basically supports the same functionality at least given your examples:

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 @@@@@"))

这篇关于VB6格式功能:模拟在.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆