如何按顺序生成 2 个小写/大写字母/数字的组合?
Sub Main()
Dim Looper As Boolean = True
While Looper = True
'String = "aa", "Aa", "aA", "AA"
'WebClient.DownloadString("link.com/" & String")
End While
End Sub
像这样,但是为 String 生成组合
如何按顺序生成 2 个小写/大写字母/数字的组合?
Sub Main()
Dim Looper As Boolean = True
While Looper = True
'String = "aa", "Aa", "aA", "AA"
'WebClient.DownloadString("link.com/" & String")
End While
End Sub
像这样,但是为 String 生成组合
您可以遍历一个字符串并根据需要操作大写和小写:
Sub Main()
Dim results as List(of String) = new List(of String)()
For Each c as Char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray()
results.Add(c.ToString().ToLower() & c.ToString().ToLower())
results.Add(c.ToString() & c.ToString().ToLower())
results.Add(c.ToString().ToLower() & c.ToString())
results.Add(c.ToString() & c.ToString())
Next
End Sub
这将生成两个随机字符的组合,包括数字和大写/小写字母:
Public Function GetRandomString(ByVal iLength As Integer) As String
Dim sResult As String = ""
Dim rdm As New Random()
For i As Integer = 1 To iLength
sResult &= ChrW(rdm.Next(32, 126))
Next
Return sResult
End Function
或者您可以执行定义有效字符的通用随机字符串:
Public Function GenerateRandomString(ByRef iLength As Integer) As String
Dim rdm As New Random()
Dim allowChrs() As Char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ0123456789".ToCharArray()
Dim sResult As String = ""
For i As Integer = 0 To iLength - 1
sResult += allowChrs(rdm.Next(0, allowChrs.Length))
Next
Return sResult
End Function