Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15634

How to generate string by specifies a maximum number of repeated characters?

$
0
0
Dear all expert programmers,

I make string with for .. next loop. I want to specifies a maximum number of repeated characters. But I can't figure out what to do. Please help me to solve this problem.

Code:

private function getGenstring(byval intLimit as byte) as string
        dim b as integer, c as integer, d as integer, e as integer, intend as integer
        dim strTemp as string
        const intend = 4
        for b=1 to intend       
                for c = 1 to intend
                        for d=1 to intend
                                for e=1 to intend
                                        strTemp=strTemp & b & c & d & e & ","
                                next
                        next
                next
        next
        getGenstr=strTemp
end function

If X=getGenstr(1)
Result will be
1234


If X=getGenstr(2)
Result will be
1122
1123
1124
1133
1134
1144
1223
1224
1233
1234
1244
1334
1344
2233
2234
2244
2334
2344
3344

If X=getGenstr(3)
Result will be
1112
1113
1114
1122
1123
1124
1133
1134
1144
1222
1223
1224
1233
1234
1244
1333
1334
1344
1444
2223
2224
2233
2234
2244
2333
2334
2344
2444
3334
3344
3444

If X=getGenstr(4)

Result will be
1111
1112
1113
1114
1122
1123
1124
1133
1134
1144
1222
1223
1224
1233
1234
1244
1333
1334
1344
1444
2222
2223
2224
2233
2234
2244
2333
2334
2344
2444
3333
3334
3344
3444
4444

Thank you for all posts.

Viewing all articles
Browse latest Browse all 15634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>