关心所有人。 我试图为此找到简单的解决方案。我的班级Mikrotik API的拨款是:
uptime=14w3d8h50m4s=version=6.30.4=build-time=Aug/25/2015 12:59:46=free-memory=67649536=total-memory=134217728=cpu=MIPS 24Kc V7.4=cpu-count=1=cpu-frequency=680=cpu-load=50=free-hdd-space=114511872=total-hdd-space=134217728=write-sect-since-reboot=159485=write-sect-total=657518=bad-blocks=0=architecture-name=mipsbe=board-name=RB433GL=platform=MikroTik
我们需要的是格式化字符串:
uptime: 14w3d8h50m46s
version: 6.30.4
build-time: Aug/25/2015 12:59:46
free-memory: 64.6MiB
total-memory: 128.0MiB
cpu: MIPS 24Kc V7.4
cpu-count: 1
cpu-frequency: 680MHz
cpu-load: 36%
free-hdd-space: 109.2MiB
total-hdd-space: 128.0MiB
write-sect-since-reboot: 159487
write-sect-total: 657520
bad-blocks: 0%
architecture-name: mipsbe
board-name: RB433GL
platform: MikroTik
一个好的解决方案是在每两个(第二个)字符=
上拆分文字,或者用vbCrLf
替换结果:
uptime=14w3d8h50m46s
version=6.30.4
build-time=Aug/25/2015 12:59:46
答案 0 :(得分:0)
我找到了一个简单的解决方案:
Dim input As String = "uptime=1w12h14m47s=version=6.30.4=build-time=Aug/25/2015 12:59:46"
Dim words As String() = input.Split(New Char() {"="c})
Dim result As String = String.Empty
Dim count As Integer = 1
For Each word In words
If count = 1 Then
count = 0
result += word + ": "
Else
result += word + vbCrLf
count += 1
End If
Next
MsgBox(result)
结果是:
uptime: 14w3d8h50m46s
version: 6.30.4
build-time: Aug/25/2015 12:59:46