vb的代码比较少发布,做一个简单的3位数组合例子(123作百位,789作十位,456作个位)
Dim aaaa = {123,789,456} 'Dim a0 = aaaa(0).ToString.ToArray,a1 = aaaa(1).ToString.ToArray,a2 = aaaa(2).ToString.ToArray Dim a = 0,b = 0,c = 0 Dim e = "" '再次演示用判断替代循环技巧 Do While a < 3 'e += (a0(a) & a1(b) & a2(c)).ToString & (IIf(a = 2 And b = 2 And c = 2,""," "))'三目运算 e += ((aaaa(0).ToString)(a) & (aaaa(1).ToString)(b) & (aaaa(2).ToString)(c)).ToString & (IIf(a = 2 And b = 2 And c = 2," ")) If c < 2 Then c += 1 Else c = 0 b += 1 End If If b = 3 Then c = 0 b = 0 a += 1 End If Loop 要得到的结果:174 175 176 184 185 186 194 195 196 274 275 276 284 285 286 294 295 296 374 375 376 384 385 386 394 395 396 如果要得到数字需要转换 aaaa = e.Split(" ").Select(Function(aa) Int32.Parse(aa)).ToArray aaaa = e.Split(" ").Select(Function(aa,index) Int32.Parse(aa)).ToArray'index带序的其实和C#的写法就差aa=>不同 以下是C#的写法 var aaa = "123".Select(aa => int.Parse(aa.ToString())); aaa = "123".Select((aa,index) => int.Parse(aa.ToString()));