人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

防范在TextBox中輸入

防范在TextBox中輸入

更新時間:2022-09-04 文章作者:未知 信息來源:網絡 閱讀次數:

方法一:(有光標閃爍,輸入、刪除等操作無效)

Text1.Locked = True

方法二:(無光標閃爍,不能輸入、刪除,界面變色、文字反白)

Text1.Enabled = False

方法三:(有光標閃爍,可刪除,不能輸入)

此法用兩個API函數,略為復雜些。請在標準工程添加兩個按鈕和一個文本框:

Option Explicit

Private Declare Function GetWindowLong Lib "user32" 
Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" 
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Const GWL_STYLE = (-16)
Const ES_NUMBER = &H2000&

Public Sub SetNumber(NumberText As TextBox, Flag As Boolean)

Dim CurrentStyle As Long, NewStyle As Long
'返回正常樣式
CurrentStyle = GetWindowLong(NumberText.hwnd, GWL_STYLE)

If Flag Then
CurrentStyle = CurrentStyle Or ES_NUMBER
Else
CurrentStyle = CurrentStyle And (Not ES_NUMBER)
End If

'設置新樣式
NewStyle = SetWindowLong(NumberText.hwnd, GWL_STYLE, CurrentStyle)
NumberText.Refresh '刷新
End Sub

Private Sub Command1_Click()
SetNumber Text1, True
Text1.SetFocus
End Sub

Private Sub Command2_Click()
SetNumber Text1, False
Text1.SetFocus
End Sub

Private Sub Form_Load()
Command1.Caption = "禁止輸入"
Command2.Caption = "可以輸入"
End Sub

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 莆田市| 辽阳县| 兰溪市| 壶关县| 两当县| 金塔县| 邮箱| 吴旗县| 循化| 五莲县| 合肥市| 建瓯市| 沙河市| 康乐县| 于都县| 金秀| 申扎县| 宝丰县| 磴口县| 田阳县| 额尔古纳市| 泰兴市| 灵武市| 宿州市| 梁平县| 武强县| 庐江县| 樟树市| 北宁市| 项城市| 望城县| 沐川县| 井研县| 金阳县| 寻甸| 若尔盖县| 拜城县| 徐闻县| 六安市| 夹江县| 友谊县|