我目前在vb.net express 2013中工作。我正在使用windows窗体应用程序。我需要从一串数字中的最后一个数字中拉出第三个数字,而不会在其后面输入其他数字。我在这个网站上发现了这个问题,Get last 5 characters in a string,这非常接近我所需要的。然而,这段代码会把所有最后5个字符都拉出来,而在我的代码中,我需要第三个没有任何其他数字。例如,如果您输入数字“917408”,则需要选择“4.”。有了这个,我将根据从原始长号码返回的号码创建一个IF语句。从vb.net中的一串数字中提取一个特定的数字
'Ghost Floor
If CBJob1.Visible Then
If Shear1.Text >= 3 Then
Dim ghostshear1 As String = Shear1.Text
Dim len = ghostshear1.Length
Dim result = ghostshear1.Substring(len - 3, 1)
MsgBox(result)
End If
End If
你只需要查看该答案并修改参数[substring](http://msdn.microsoft.com/en-us/library/system.string.substring(v = vs.110).aspx )并根据您的需要稍微修改它。 – Plutonix 2014-09-22 19:17:21
字符串中的第四个数字是'myString.Chars(3)'或'myString.Substring(3,1)'。请参阅[这里](http://msdn.microsoft.com/en-us/library/aka44szs(v = vs.110).aspx)和[here](http://msdn.microsoft.com/en-us /library/system.string.chars(v=vs.110).aspx) – 2014-09-22 19:18:42
'LEFT(RIGHT(string,3),1)' – RBarryYoung 2014-09-22 19:19:08