Microsoft Office Excel ® Kod Kılavuzu

Microsoft Office Excel® Code Guide

10 Şubat 2009 Salı

ActiveControl [ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)]


'UserForm1

Option Explicit
Dim i As Long
Dim sText As String


Private Sub UserForm_Initialize()
On Error Resume Next
With ComboBox1
.AddItem "Per"
.AddItem "Person"
.AddItem "Personal"
.AddItem "Personality"
End With
End Sub
Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
On Error Resume Next
If KeyAscii = vbKeyReturn Then
SendKeys "{tab}"
KeyAscii = 0
Exit Sub
End If
With Me.ActiveControl
If (KeyAscii = vbKeyBack And .SelStart > 0) Then
sText = Left$(.Text, .SelStart - 1)
Else
sText = Left$(.Text, .SelStart) & Chr(KeyAscii)
End If
KeyAscii = 0
For i = 0 To .ListCount - 1
If UCase$(sText) = UCase$(Left$(.List(i), Len(sText))) Then
.ListIndex = i
.Text = .List(i)
.SelStart = Len(sText)
.SelLength = Len(.List(i)) - (Len(sText))
Exit For
End If
Next i
End With
End Sub

Hiç yorum yok:

Blog Arşivi

Bu gadget'ta bir hata oluştu

Bu Blogda Ara

Contributor

Contributor
Mustafa ULUSARAÇ İstanbul, TÜRKİYE
free counters
T. C. Central Bank Indicative Exchange Rates
Currency Exchange Rate Widget,Currency Converter Widget
Borsa İstanbul