vb.net 旧的visual basic mid和left函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19460366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Old visual basic mid and left functions
提问by XK8ER
I am using old code from vb but I would like to know whats the best approach for vb.net new code..
我正在使用 vb 中的旧代码,但我想知道 vb.net 新代码的最佳方法是什么..
test = Mid(strData, Pos1 + Len(strFirst))
test = Mid(strData, Pos1 + Len(strFirst) + 3 + Len(strID))
test = Microsoft.VisualBasic.Left(strID, Pos2 - 1)
回答by ElektroStudios
Since you are not supplying the data contents of variables: strDatastrIDstrFirstPos1Pos2I can't write a better code to explain, but this example should be sufficient.
由于您没有提供变量的数据内容:strDatastrIDstrFirstPos1Pos2我无法编写更好的代码来解释,但是这个示例应该足够了。
Equivalent of VB6functions:
等效VB6功能:
Len = "String".Length
Left = "String".Substring(0, length)
Mid = "String".Substring(start position, length)
Then VB.NETcode translation should looks like this:
然后VB.NET代码翻译应该是这样的:
test = strData.Substring(pos1 + strFirst.length)
test = strData.Substring(pos1 + strFirst.length + 3 + strID.length)
test = strID.Substring(Pos2 - 1)

