小编yar*_*r83的帖子

如何从字符串中获取整数?

我从旧文件中抓取了文本,需要获取放置在字符串中的数字数据。

字符串看起来像:

"season: 1983 colony: 23 colony weight: 4 kg yeild: 12 kg
"season: 1983 colony:- colony weight: 5 kg yeild: 14 kg"
Run Code Online (Sandbox Code Playgroud)

我做了一个函数,它接受一个原始数据字符串并返回一个整数数组。

Function getClearBeeData(rawData As Variant) As Integer()
  Dim retValue(4) As Integer 'array where each found number stored
  Dim strTempString As String 'temporary string to hold current number
  Dim i, k As Integer 'i counter for original string, k counter for array position
  Dim token As Boolean 'token shows whether previous chars were number
  token = False
  
  For …
Run Code Online (Sandbox Code Playgroud)

excel vba

1
推荐指数
1
解决办法
155
查看次数

标签 统计

excel ×1

vba ×1