當前位置:編程學習大全網 - 網站源碼 - 誰有編程隨機產生驗證碼(4位數字或者字母)最精簡的算法(VB)

誰有編程隨機產生驗證碼(4位數字或者字母)最精簡的算法(VB)

首先要畫3個控件

1、lacel1

2、text1

3、Command1

隨機數字產生在

lacel1控件裏面

text1

輸入隨機數字

Command1

單擊時驗證隨機數

具體代碼如下

Dim

txt

As

String

'全局變量txt為字符型

Private

Sub

Form_Load()

' 加載模塊時label1.caption

會變成壹個隨機1000

-

9999

的數字

Randomize

txt

=

Int(Rnd

*

(9999

-

1000

+

1)

+

1000)

'寫出1000

-

9999

的隨機數字

Label1.Caption

=

txt

End

Sub

Private

Sub

Label1_Click()

點擊時label1.caption

會刷新成壹個隨機1000

-

9999

的數字

Randomize

txt

=

Int(Rnd

*

(9999

-

1000

+

1)

+

1000)

'寫出1000

-

9999

的隨機數字

Label1.Caption

=

txt

End

Sub

Private

Sub

Command1_Click()

'單擊command1_click()

驗證隨機數

If

Text1.Text

=

txt

Then

MsgBox

"驗證正確"

End

If

End

Sub

  • 上一篇:網易郵箱微博頁查看郵件什麽意思
  • 下一篇:飛傲dac用fb2k經常播不了dsf dff
  • copyright 2024編程學習大全網