'// membutuhkan 1 Combobox
'By: eko cahyono Ym:eko_matrix
Private cekKey As Boolean
Private Sub Combo1_Change()
Static ChangeFlag As Boolean
Dim cboText As String
Dim lencboText As Integer
Dim tmpLen As Integer
Dim tmp As Integer
If Not ChangeFlag Then
cboText = Combo1.Text
lencboText = Len(Combo1.Text)
If Not cekKey Then
For tmp = 0 To Combo1.ListCount - 1
If UCase(Left(Combo1.Text, Combo1.SelStart)) = UCase _
(Combo1.List(tmp)) Then
ChangeFlag = True
Combo1.Text = Combo1.List(tmp)
Combo1.SelStart = Len(Combo1.Text)
ChangeFlag = False
cekKey = False
Exit Sub
End If
Next tmp
If lencboText > 0 Then
For tmp = 0 To Combo1.ListCount - 1
If UCase(Left(Combo1.List(tmp), _
lencboText)) = UCase(cboText) Then
tmpLen = lencboText
ChangeFlag = True
Combo1.Text = Combo1.List(tmp)
Combo1.SelStart = tmpLen
Combo1.SelLength = Len(Combo1.List( _
tmp)) - tmpLen
ChangeFlag = False
Exit For
End If
Next tmp
End If
End If
cekKey = False
End If
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyDelete) Or (KeyCode = vbKeyBack) Then
cekKey = True
End If
End Sub
Jumat, 14 November 2008