|
-
Dec 14th, 1999, 12:05 PM
#2
Lively Member
You could change this style of the combo to "dropdown list" and the user will only be able to select what is in the list. I you really need to let them type stuff in then this should work,
Drop a combo onto a form and paste the following code
Option Explicit
Dim sArray(2) As String
Private Sub Combo1_Change()
Dim i As Integer
Dim sCompare As String
Dim bOk As Boolean
sCompare = Combo1.Text
For i = 0 To UBound(sArray)
If Len(sArray(i)) >= Len(sCompare) Then
If Left(sArray(i), Len(sCompare)) = sCompare Then
bOk = True
Exit For
End If
End If
Next
If Not bOk Then
If Len(Combo1.Text) > 1 Then
Combo1.Text = Left(Combo1.Text, Len(Combo1.Text) - 1)
Else
Combo1.Text = ""
End If
End If
Combo1.SelStart = Len(Combo1.Text)
End Sub
Private Sub Form_Load()
Dim i As Integer
sArray(0) = "one"
sArray(1) = "two"
sArray(2) = "three"
For i = 0 To 2
Combo1.AddItem sArray(i)
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|