发布网友 发布时间:2022-04-23 06:56
共4个回答
热心网友 时间:2022-06-17 03:03
程序代码:
使用示例1(帖子要求的长度26的超级单词):
使用示例2(随机长度的随机单词):
程序代码文本(有可能特殊符号被浏览器偷吃,以上图代码为准):
Option Explicit
Function 随机不重复字母串(Optional ByVal n& = 26) As String
Dim a(1 To 26), i&, j&, s$
'初始化
For i = 1 To 26
a(i) = Chr(64 + i)
Next i
'打乱
For i = 1 To 26
j = Int(Rnd() * 26 + 1)
s = a(j)
a(j) = a(1)
a(1) = s
Next i
'随机小写
For i = 1 To 26
j = Int(Rnd() * 26 + 1)
If a(j) < "a" Then a(j) = Chr(Asc(a(j)) + 32)
Next i
'合成和返回
随机不重复字母串 = Left(Join(a, ""), n)
End Function
热心网友 时间:2022-06-17 03:04
A1中空着,B1中输入热心网友 时间:2022-06-17 03:04
选中A2:Z2,输入数组公式=CHAR(CHOOSE(MOD(COLUMN(A1:Z1),2)+1,65,97)+MOD(SMALL(RANDBETWEEN(-A1:Z1,50)/1%+COLUMN(A1:Z1),COLUMN()),100)-1)热心网友 时间:2022-06-17 03:05
代码视图:
计算结果:
代码如下:
'复制到模块
Function Exchange()
Dim Arr1(25) As String, i%, j, K, Rndrange As Long, Rnd1 As Double
'生成26个英文大写字母
For i = 0 To 25
Arr1(i) = Chr(65 + i)
Next i
Rndrange = UBound(Arr1)
'交换数组元素位置
For j = 0 To 25
Randomize (Timer)
Rnd1 = Int(Rndrange * Rnd)
K = LCase(Arr1(j))
Arr1(j) = Arr1(Rnd1)
Arr1(Rnd1) = K
Next j
Exchange = Join(Arr1) '不重复的数列
End Function