用VB产生随机密码
VERSION 5.00
Begin VB.Form frmMain
Caption = "Produce random num"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
LockControls = -1 注释:True
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 注释:系統預設值
Begin VB.TextBox txtDigit
Height = 285
Left = 810
MaxLength = 2
TabIndex = 2
Text = "5"
Top = 2460
Width = 465
End
Begin VB.ListBox lstPassWord
Height = 1860
Left = 60
TabIndex = 1
Top = 210
Width = 4455
End
Begin VB.CommandButton cmdOK
Caption = "GetRandPassword"
Height = 375
Left = 2610
TabIndex = 0
Top = 2400
Width = 1575
End
Begin VB.Label Label1
Alignment = 2 注释:置中對齊
Caption = "Double Click to copy the selected item to clipboard."
Height = 195
Left = 0
TabIndex = 4
Top = 2970
Width = 4695
End
Begin VB.Label lbDigit
Caption = "digits:"
Height = 255
Left = 210
TabIndex = 3
Top = 2460
Width = 525
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdOK_Click()
Dim strArray() As String, str As String, strPWD As String
Dim i As Integer, iDigit As Integer, ilen As Integer
str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
str = str & LCase(str) & "0123456789-=[];注释:,./"
str = str & ")!@#$%^&*(_+|{}:""<>?"
ilen = Len(str)
iDigit = txtDigit.Text
strPWD = ""
For i = 0 To iDigit - 1
Randomize
strPWD = strPWD & Mid(str, Int(ilen * Rnd() + 1), 1)
Next
lstPassWord.AddItem strPWD
End Sub
Private Sub Form_Load()
lstPassWord.FontSize = 11
lstPassWord.ForeColor = RGB(255, 0, 0)
End Sub
Private Sub lstPassWord_DblClick()
Clipboard.SetText lstPassWord.Text
End Sub
Begin VB.Form frmMain
Caption = "Produce random num"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 注释:系統預設值
Begin VB.TextBox txtDigit
Height = 285
Left = 810
MaxLength = 2
TabIndex = 2
Text = "5"
Top = 2460
Width = 465
End
Begin VB.ListBox lstPassWord
Height = 1860
Left = 60
TabIndex = 1
Top = 210
Width = 4455
End
Begin VB.CommandButton cmdOK
Caption = "GetRandPassword"
Height = 375
Left = 2610
TabIndex = 0
Top = 2400
Width = 1575
End
Begin VB.Label Label1
Alignment = 2 注释:置中對齊
Caption = "Double Click to copy the selected item to clipboard."
Height = 195
Left = 0
TabIndex = 4
Top = 2970
Width = 4695
End
Begin VB.Label lbDigit
Caption = "digits:"
Height = 255
Left = 210
TabIndex = 3
Top = 2460
Width = 525
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdOK_Click()
Dim strArray() As String, str As String, strPWD As String
Dim i As Integer, iDigit As Integer, ilen As Integer
str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
str = str & LCase(str) & "0123456789-=[];注释:,./"
str = str & ")!@#$%^&*(_+|{}:""<>?"
ilen = Len(str)
iDigit = txtDigit.Text
strPWD = ""
For i = 0 To iDigit - 1
Randomize
strPWD = strPWD & Mid(str, Int(ilen * Rnd() + 1), 1)
Next
lstPassWord.AddItem strPWD
End Sub
Private Sub Form_Load()
lstPassWord.FontSize = 11
lstPassWord.ForeColor = RGB(255, 0, 0)
End Sub
Private Sub lstPassWord_DblClick()
Clipboard.SetText lstPassWord.Text
End Sub