本文介绍了得到一串数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串abcd 36.2如何仅获取36.2的值,可以更改abcd吗?
i have a string abcd 36.2 How to get the value 36.2 only , with abcd can be changed?
推荐答案
<br /> '' Test data<br /> Dim testData As String = "abcd 36.2"<br /> '' String to hold the wanted info<br /> Dim numericValue As String = String.Empty<br /> '' A regular Expression to pull out the needed info<br /> Dim m As Match = Regex.Match(testData, "^.*?(\d+(?:\.\d+)?)")<br /> '' Test to see if the string had a numeric value on the end of it<br /> If m.Success Then<br /> '' Pull out the information<br /> numericValue = m.Groups(1).Value<br /> End If<br /><br /> MessageBox.Show("Numeric Value = " & numericValue)<br />
Fernando
Fernando
Dim x As String = "abcd 36.2"<br /> Dim value As String = ""<br /> For lp As Integer = 0 To x.Length - 1<br /> If IsNumeric(x.Chars(lp)) Or x.Chars(lp) = "." Then<br /> value &= x.Chars(lp)<br /> End If<br /> Application.DoEvents()<br /> Next<br /> MsgBox(value)
希望这会有所帮助
Anoop
hope this helps
Anoop
这篇关于得到一串数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!