تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
a AutoComplete Very Simple!
#1
كود :
                '**************************************
' Name: a AutoComplete Very Simple!
' Description:VERY SIMPLE cut and paste funtion for the Keypress event of a combobox. Just paste this code into a module or form and call the function from the KeyPress event. KeyAscii = AutoComplete(cboCombobox, KeyAscii,Optional UpperCase)
' By: ( . Y . ) (from psc cd)
'**************************************

Option Explicit
Public Const CB_FINDSTRING = &H14C
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Function AutoComplete(cbCombo As ComboBox, sKeyAscii As Integer, Optional bUpperCase As Boolean = True) As Integer
Dim lngFind As Long, intPos As Integer, intLength As Integer
Dim tStr As String
With cbCombo
If sKeyAscii = 8 Then
If .SelStart = 0 Then Exit Function
.SelStart = .SelStart - 1
.SelLength = 32000
.SelText = ""
Else
intPos = .SelStart '// save intial cursor position
tStr = .Text '// save string
If bUpperCase = True Then
.SelText = UCase(Chr(sKeyAscii)) '// change string. (uppercase only)
Else
.SelText = UCase(Chr(sKeyAscii)) '// change string. (leave case alone)
End If
End If

lngFind = SendMessage(.hwnd, CB_FINDSTRING, 0, ByVal .Text) '// Find string in combobox
If lngFind = -1 Then '// if string not found
.Text = tStr '// set old string (used for boxes that require charachter monitoring
.SelStart = intPos '// set cursor position
.SelLength = (Len(.Text) - intPos) '// set selected length
AutoComplete = 0 '// return 0 value to KeyAscii
Exit Function

Else '// If string found
intPos = .SelStart '// save cursor position
intLength = Len(.List(lngFind)) - Len(.Text) '// save remaining highlighted text length
.SelText = .SelText & Right(.List(lngFind), intLength) '// change new text in string
'.Text = .List(lngFind)'// Use this instead of the above .Seltext line to set the text typed to the exact case of the item selected in the combo box.
.SelStart = intPos '// set cursor position
.SelLength = intLength '// set selected length
End If
End With

End Function
الرد }}}
تم الشكر بواسطة: Ahmed_Mansoor , Ahmed_Mansoor , Amir_Alzubidy , asemshahen5 , awidan76 , awidan76
#2
السلام عليكم ورحمة الله وبركاته

أهلا بك أخي الكريم , بارك الله فيك وجزاك الله كل خير , كود جميل ومفيد .
كود :
For Each Breathe in MyLife
Breathe.Say " سبحان الله والحمد لله ولا إله إلا الله والله أكبر أستغر الله العظيم وأتوب إليه"
Next
الرد }}}
تم الشكر بواسطة: viv , viv , Amir_Alzubidy , asemshahen5 , awidan76
#3
جزاك الله خيرا

احترمك
اعز معلمين :
1) Ahmed _Mansoor
2) sniper.ps 
3) myalsailamy
4) ahmedabdelaliem 
5) sendbad100
6)Amir_alzubidy

الرد }}}
تم الشكر بواسطة: asemshahen5 , viv
#4
بوركت عزيزي
الرد }}}
تم الشكر بواسطة: awidan76


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  A simple Wait Function viv 1 1,364 18-08-19, 05:43 AM
آخر رد: Ahmed_Mansoor

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم