日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

学生系统优化——字符限定

發布時間:2023/12/9 windows 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 学生系统优化——字符限定 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、文本框限定

1、限定輸入的字符長度

文本框中有個MaxLength屬性,輸入自己要限定的數字即可;也可以利用代碼來限定,當超過限定長度時,彈出警告對話窗

Private sub txtUserName_change()If Len(Trim(txtUserName)) > 4?thenMsgBox "姓名不能超過4個字符,請重新輸入!", 0 + 48txtUserName = ""End if? End iSub

Trim函數是消除字符串的空格,Len函數是計算字符串的長度

2、限定特殊字符

Private Sub txtUserName_Change()If Len(Trim(txtUserName)) > 4 thenMsgBox "姓名不能超過4個字符,請重新輸入!", 0 + 48txtUserName = ""End if End sub

3、限定輸入的字符類型

Private Sub txtSID_KeyPress(KeyAscii As Integer)Const xStr As String = "123456" '只能輸入數字KeyAscii = IIf(Instr(xStr & Chr(8), Chr(KeyAscii)), KeyAscii, 0) End Sub

4、限定特殊字符

Private Sub txtDirector_KeyPress(KeyAscii As Integer)Select Case KeyAsciiCase 8 '限制退格鍵Case Asc("A") To ("Z")Case Asc("a") To ("z")Case Is < 0Case ElseKeyAscii = 0MsgBox "格式錯誤,請輸入漢字或英文!", 0 + 48txtDirector.Text = ""End Select End Sub

5、只能輸入數字

If keyAscii = 8 Then Exit Sub If keyAscii < 48 Or keyAscii > 57 Then keyAscii = 0

6、限制數字大小,這個適合成績對話框

Private Sub txtResult_change() On Error Resume Next If Val(Trim(txtResult.Text)) > 100 Then MsgBox "輸入數字過大,請重新輸入" txtResult.Text = "" End If End Sub

?7、不能輸入特殊字符(和第二、四個一樣的性質)

Select Case keyAscii Case -20319 To -3652 Case 48 To 57 Case 65 To 98 Case 97 To 122 Case 8 Case Else keyAscii = 0 End Select

?8、限定特殊字符、數字、空格,只能輸入漢字和字母

Private Sub txtCourseName_KeyPress(KeyAscii As Integer)If KeyAscii < 0 or KeyAscii = 8 or KeyAscii = 13 ThenElse IfNot chr(KeyAscii) Like "[a-ZA-Z]" ThenkeyAscii = 0End if End sub

二、下拉框限定?

Combox限定不能鍵盤輸入,只能選擇下拉框里面的內容

Private Sub comboGrade_KeyPress(KeyAscii As Integer)KeyAscii = 0 '限制鍵盤不能輸入內容 End Sub

三、限定成績

Private Sub txtResult_Change()If Val(txtResult.Text) > 120 Or Val(txtResult.Text) < 0 ThenMsgBox "請輸入成績在0~120范圍內!", 0 + 48txtResult.Text = ""End If End Sub

四、限定不能復制粘貼

在第二次輸入密碼時,不能復制粘貼

Private Sub txtPassword1_KeyDown(KeyCide As Integer, Shift As Integer)If (KeyCode = 86 Or KeyCode = 67 Or KeyCode = 88) And Shift = 2 ThenMsgBox "不能復制粘貼", 0 + 48txtPassword1.Text = ""End If End Sub

提示密碼剩余次數

If miCout = 1 ThenMsgBox "您還有兩次機會", 0 + 48,"提示" Exit sub End IfIf miCout = 2 ThenMsgBox "您還有一次機會", 0 + 48,"提示" Exit sub End IfIf miCout = 3 ThenMsgBox "即將關閉程序", 0 + 48,"提示"Me.Hide Exit sub End If

?

?

?

?

??

總結

以上是生活随笔為你收集整理的学生系统优化——字符限定的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。