0
string = "I was born in = 1994"

如何将“=”之后的所有值存储在var中?

4

3 回答 3

3

这是最简单的方法:

Dim var = s.Substring(s.IndexOf("="c) + 1)
于 2012-05-01T20:09:17.490 回答
1

您可以使用拆分功能:

  Dim [string] = "I was born in = 1994"
  Dim temp() As String = Split([string], " = ", -1, CompareMethod.Binary)
  'now value is in temp(1)
  MessageBox.Show(temp(1))
于 2012-05-02T07:47:57.360 回答
0

有很多方法,我会在字符串中使用。

mystring as new string
mystring  = "I was born in =1994"
DataAfterEquals as string = mid(mystring,instr(mystring,"=")+1,mystring.length-instr(mystring,"=")+1)

您当然可以使用正则表达式,使用拆分,然后您当然可以采用非常老式的方式并遍历字符串以找到等号。

上面的代码会找到第一个等号,然后从字符串中的那个点向外解析,所以我添加了+1来跳过等号。这个伪代码。

于 2012-05-01T20:14:46.797 回答