首页 > 解决方案 > VB6 到 VB.Net 的“命令”是什么?

问题描述

我正在将应用程序从 VB6 迁移到使用命令表达式的 VB.Net。

我的问题是:以下代码中 VB6命令的“等价物”是什么?$ 在 VB6 中返回字符串。所以我可以删除它......但即使在删除$之后, Command 也会给我一个错误,即Command 是一种接口类型,不能用作表达式。

在此处输入图像描述

我会尝试写'New Command().CommandText'来代替Command。这是正确的写作方式吗?

标签: vb.netvb6migrationvb6-migration

解决方案


VB6Command$在 VB.NET 中的等效函数是Environment.CommandLine

请参考下面的代码示例:

Class Example
   Public Shared Sub Main()
      Console.WriteLine()
      '  Invoke this sample with an arbitrary set of command line arguments.
      Console.WriteLine("CommandLine: {0}", Environment.CommandLine)
   End Sub 
End Class 
' The example displays output like the following:
'       C:\>CommandLine ARBITRARY TEXT
'       
'       CommandLine: CommandLine ARBITRARY TEXT

如果你想得到一个命令行参数的数组,你可以使用Environment.GetCommandLineArgs


推荐阅读