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

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.