我想从地狱中找到最后5位数/位数。 例如,<代码> 我将到2011年<<>>>>>>学校读到“2011年>>>>>。
任何想法? 我知道视觉基础有<条码> 权利(显示,5)条码>;这给我带来了错误。
我想从地狱中找到最后5位数/位数。 例如,<代码> 我将到2011年<<>>>>>>学校读到“2011年>>>>>。
任何想法? 我知道视觉基础有<条码> 权利(显示,5)条码>;这给我带来了错误。
str.Substring(str.Length - 5)
校外检查:
result = str.Substring(Math.Max(0, str.Length - 5))
错误核对:
Dim result As String = str
If str.Length > 5 Then
result = str.Substring(str.Length - 5)
End If
旧读,但只是说:使用经典的<代码>,Right(
,Mid(>
),现在你不需要写全条道路()。 微软.VisualBasic.Strings
。 你们可以快速、轻易地利用:
Strings.Right(yourString, 5)
在VB 2008年(VB 9.0)和后来作为微软的预先设定权利。 视觉基础。 权利(特征、数量)
Dim str as String = “Hello World”
Msg Box (Microsoft.VisualBasic.Right(str,5)
世界”
Same也站在左边。
该员额的公认答案将造成5年以下的错误。 因此,我有更好的解决办法。 我们可以利用这一简单法典:
If(str.Length <= 5, str, str.Substring(str.Length - 5))
你们可以用不同的长度加以测试。
Dim str, result As String
str = "11!"
result = If(str.Length <= 5, str, str.Substring(str.Length - 5))
MessageBox.Show(result)
str = "I will be going to school in 2011!"
result = If(str.Length <= 5, str, str.Substring(str.Length - 5))
MessageBox.Show(result)
另一种简单但有效的解决办法是:
str. Substring(str.Length - Math.Min(5,str.Length)
Dim a As String = Microsoft.VisualBasic.right("I will be going to school in 2011!", 5)
MsgBox("the value is:" & a)
I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...
I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?
I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...
I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...
On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...
I have a relatively simple question regarding the best way to call the DataGridView.Rows.Add function when it is inherited into the current control. Which is the best way to make the call to the ...
I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?
Can I use two command object with one open connection in one procedure at VB.NET?