當前位置:成語大全網 - 新華字典 - vb源代碼解釋,解釋的越詳細越好,希望是高手,說我能聽懂的解釋。這是壹個生成密碼字典器源碼,我是新手

vb源代碼解釋,解釋的越詳細越好,希望是高手,說我能聽懂的解釋。這是壹個生成密碼字典器源碼,我是新手

Option?Explicit?'強制顯示聲明,即變量必須先定義後使用

Dim?ss?As?String?'定義變量ss是字符串型,並且默認初始值是空串

Private?Sub?Command1_Click()?'按鈕Command1單擊事件

ss?=?ss?&?UCase("abcdefghijklmnopqrstuvwxyz")?'UCase函數是格式化為大寫

ss?=?ss?&?"abcdefghijklmnopqrstuvwxyz"'&是字符串連接函數

ss?=?ss?&?"0123456789"

ss?=?ss?&?"~!@#$%^&*()_+{}|:<>?[]\;',./"

'至此,ss="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~!@#$%^&*()_+{}|:<>?[]\;',./"

Dim?passwordlen?As?Double'定義變量passwordlen是雙精度型,用於設定密碼最大長度

Dim?icount?As?Double?'定義變量icount是雙精,

Dim?s1?As?String?'定義變量s1是字符串型,

Dim?i,?j?As?Double'定義變量i是變體型,j是雙精度型

Dim?count?As?Double?'定義變量count是雙精度型號

Dim?password()?As?String?'定義動態數組password()?是字符串型,

Dim?tempstr?As?String'定義變量tempstr是字符串型,

passwordlen?=?Val(Text1.Text)'文本框Text1中的字符型轉換為數值型,存到變量passwordlen

If?passwordlen?<?1?Then?'當passwordlen小於1

MsgBox?"請輸入密碼最大長度",?vbInformation,?"字典生成工具"?'彈出對話框

Text1.SetFocus'文本框Text1獲得焦點

Exit?Sub?'退出sub過程

End?If

List1.Clear?'初始化,清空列表框List1

icount?=?Len(ss)?'把字符創ss的長度值90放入變量icount

For?i?=?1?To?icount?'for循環,初值是1,終值是90,步進是1

ReDim?Preserve?password(i)'重新定義動態數組password()的下屆是i(上界是0),Preserve是保留不替換

password(i)?=?Mid$(ss,?i,?1)?'數組password的每壹個元素是字符串ss中第i的位置取壹個

List1.AddItem?password(i)'把數組的所有元素顯示到列表框List1中

Next?i

For?i?=?2?To?passwordlen?'從2到密碼最大長度passwordlen

password?=?zuhe(password,?icount,?ss)?'調用函數zuhe

Next?i

End?Sub

Public?Function?zuhe(temp()?As?String,?icount?As?Double,?ss?As?String)?As?String()?'定義函數zuhe

'有3個自變量:數組temp()是字符串型,icount是雙精確型,?ss是字符串型

Dim?count?As?Double?'定義變量count是雙精度型

Dim?s1?As?String'定義變量s1是字符串型,

Dim?i?As?Double?'定義變量i是雙精度型

Dim?j?As?Double?'定義變量j是雙精度型

count?=?UBound(temp)'把數組temp()?的下屆存到變量count

Dim?password()?As?String'定義數組password()是字符串型,

Dim?iindex?As?Double'定義變量iindex是雙精度型

iindex?=?1?'給iindex賦予初值1

Dim?tempstr?As?String'定義變量tempstr是字符串型,

For?i?=?1?To?count

For?j?=?1?To?icount

s1?=?Mid$(ss,?j,?1)?'mid函數是從字符串ss中第j位取1位,然後賦值給變量s1

DoEvents'延時函數,防止程序假死的,

ReDim?Preserve?password(iindex)?'重新定義動態數組password()

password(iindex)?=?temp(i)?&?s1?'數組temp(i)和字符串s1連接後賦值給數組password()

List1.AddItem?password(iindex)?'把數組password()的元素顯示在列表框List1裏面

Next?j

Next?i

zuhe?=?password?'把數組password賦值給變量zuhe,作為本函數的函數值

End?Function