VB6最大化、最小化命令
Me.WindowState = 0 '0為普通,1為最小,2為最大
當(dāng)窗口大小化時(shí)發(fā)生事件
Private Sub Form_Resize() '
如果父窗體被最小化發(fā)生事件
If Form1.WindowState = vbMinimized Then
★文本框自動(dòng)剔除常用符號(hào)及空格,只保留漢字及數(shù)字的VB代碼
'數(shù)字0-9 的Ascii碼是 48-57
'字母A-Z 的Ascii碼是 65-90 小寫(xiě)字母是 97-122 (下面代碼是使用Ucase函數(shù)轉(zhuǎn)為大寫(xiě),所以我97-122從缺)
'漢字 16進(jìn)制區(qū)間 B0A1-F7FE B=66 F=70(下面代碼是使用16進(jìn)制碼的第一位,其它英文字,數(shù)字與符號(hào)的16進(jìn)制第一碼不會(huì)在B-F之間)
'添加 Command1
Dim i%, h$, aa$, bb$
Private Sub Command1_Click()
aa = "科!@#杰!@#¥在@!@#@線"
bb = ""
For i = 1 To Len(aa)
h = Hex(Asc(Mid(aa, i, 1)))
If (Asc(Left(h, 1)) >= 66 And Asc(Left(h, 1)) <= 70) Or (Asc(Mid(UCase(aa), i, 1)) >= 65 And Asc(Mid(UCase(aa), i, 1)) <= 90) Or (Asc(Mid(UCase(aa), i, 1)) >= 48 And Asc(Mid(UCase(aa), i, 1)) <= 57) Then
bb = bb & Mid(aa, i, 1)
End If
Next i
MsgBox bb
End Sub
VB6的文本框只能輸入數(shù)字和VB只能輸入一小小數(shù)點(diǎn)的方法
Private Sub Text1_KeyPress ( KeyAscii As Integer )
If KeyAscii > = Asc ( "0" ) And KeyAscii < = Asc ( "9" ) Or KeyAscii = 8 Or KeyAscii = Asc ( "." ) Then
If KeyAscii = Asc ( "." ) And InStr ( 1, Text1.Text, ".", vbTextCompare ) > 0 Then
KeyAscii = 0
End If
If Text1.SelStart > = Len ( Text1.Text ) - 2 And _
InStr ( 1, Text1.Text, ".", vbTextCompare ) > 0 And _
Len ( Text1.Text ) - InstrRev ( Text1.Text, ".", Len ( Text1.Text ) , vbTextCompare ) > = 2 And _
KeyAscii <> 8 Then
KeyAscii = 0
End If
Else
KeyAscii = 0
End If
End Sub
更強(qiáng)大更實(shí)用的限制文本框只能輸入特定字符的方法
調(diào)用方法
http://pan.baidu.com/share/link?shareid=214382&uk=1711549925
★VB文本框保留小數(shù)點(diǎn)后3位
x = Text2.Text
Text1.Text = Format(x, "0.000")
★vb窗口置頂代碼
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Const SWP_NOMOVE = &H2 '不更動(dòng)目前視窗位置
Const SWP_NOSIZE = &H1 '不更動(dòng)目前視窗大小
Const HWND_TOPMOST = -1 '設(shè)定為最上層
Const HWND_NOTOPMOST = -2 '取消最上層設(shè)定
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Private Sub Form_Load()
If App.PrevInstance = True Then End '防止程序重復(fù)運(yùn)行
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS '窗口置頂
End Sub
★visual Basic 6 如何給窗體窗口加上透明度
'窗口透明度聲明開(kāi)始
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
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
'窗口透明度聲明結(jié)束
'窗體透明度開(kāi)始
Private Sub Form_Activate()
On Error Resume Next
For i = 0 To 200 Step 5 '0-200是窗體的透明度.從0開(kāi)始到150.漸漸出現(xiàn)窗體.步長(zhǎng)為5
SetLayeredWindowAttributes Me.hwnd, 0, i, LWA_ALPHA
DoEvents
Next i
End Sub '窗體透明度結(jié)束
綜合報(bào)道 經(jīng)濟(jì)形勢(shì) 勞動(dòng)就業(yè) 政策法規(guī) 熱點(diǎn)推薦 創(chuàng)業(yè)新聞 創(chuàng)業(yè)指導(dǎo) 創(chuàng)業(yè)課堂 創(chuàng)業(yè)故事 大學(xué)生創(chuàng)業(yè) | 裝修日記 | 學(xué)駕駛經(jīng)歷 | 免費(fèi)信息發(fā)布 | 網(wǎng)站地圖
地址:合肥市臨泉路香格里拉花園 郵箱:pc354@163.com QQ:55769640 | 皖I(lǐng)CP備06007228號(hào)
版權(quán)所有:科杰服務(wù)(www.www.yeewaa.com) 建議使用IE7.0或以上版本,最少1280分辨率瀏覽本站,可獲得最佳瀏覽效果