WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

StrFixLeft Issue

 Keywords: StrFixLeft 

Question:

Seeing unexpected results when using StrFixLeft.
For j=8 to 11
k = StrFixLeft(j, "0", 2)
Next
get 08 09 10 11 <--as expected
For j=8 to 11
k = StrFixLeft(j, "000", 2)
Next
get 0008 0009 10 11 <--- huh???

Answer:

What happened there is that you specified pad to 2 characters and provided a 3 character pad-string. So, when 8 and 9 were less then 2 characters, StrFixLeft added your pad string. 10 and 11 were already 2 characters, so they were left alone.

To pad to 4 characters you should use this code:

For j = 8 To 11
k = StrFixLeft(j,"0",4)
Next

Article ID:   W17410
File Created: 2008:04:10:15:09:38
Last Updated: 2008:04:10:15:09:38