Monday 20 May 2013

Print some charaters from a string

'Set printlength for total number of character to be displayed
printLength = 4

'Source String 
myString ="12345678ABCDEFGHIJ"

'Logic
stringLength = len(myString)

for i =0 to stringLength / printLength
     myAns = myAns & vbcrlf & mid(myString  ,i*printLength +1,printLength)
next
msgbox myAns


OUTPUT -  message box with these output
=======
1234 
5678
ABCD
EFGH
IJ

No comments:

Post a Comment