VB.net 生成随机数的小代码

前端之家收集整理的这篇文章主要介绍了VB.net 生成随机数的小代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Public Shared Function NewPassword() As String

Dim PasswordParent As String = "0123456789ABCDENGHJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%&*"

Dim RetVal As String = ""

Dim Rnd As Random = New Random(System.DateTime.Now.Millisecond) '通过日期产生随机

For i As Integer = 0 To 8

Dim iRandNum As Integer = Rnd.Next(PasswordParent.Length)

RetVal += PasswordParent(iRandNum) '每次生一个随机数加入数组

Next i

Return RetVal

End Function

原文链接:https://www.f2er.com/vb/262195.html

猜你在找的VB相关文章