0

I am in the process of getting output just like below,

Res: 10Test from Res:10 Test using Append Format.

but when tried this below code,nothing happened and i am getting as Res:10 Test

Please let me know what is wrong with Append Format in my code and more info here

dim arr
arr=Array("Res:10 Test","Res:80 Test","Res:30 Test")
Set oSB  = CreateObject( "System.Text.StringBuilder" )

for each inpt in arr
  Ispt=split(inpt," ")
  oSB.AppendFormat_2 "{0}{1,4}",Ispt(0),Ispt(1)
  Ispt=oSB.ToString()
next
Community
  • 1
  • 1
J_Coder
  • 707
  • 5
  • 14
  • 32

1 Answers1

1

Your Split() does not work as you imagined:

>> a = Split("Res:80 Test")
>> WScript.Echo "|" & Join(a, "|") & "|"
>>
|Res:80|Test|

So the .AppendFormat can't left pad the number 80. In my answer I made some effort to check the results of the Split and I demoed a RegExp approach that 'works' for cases (VBscript) Split can't handle (mixed separators).

Community
  • 1
  • 1
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96