Combo_TypeAhead
Allows the VB combobox to have a type-ahead feature like the combobox in Access. If there are any matching items in the combobox list, it will automatically "fill in" the missing portions of the item and select it. This will work for multiple characters, not just the first character of the string. *** This is an expanded version of the original code *** The updates allow for new items to be added into the list, automatically. It also will handle the delete key (the previous code did not.)
สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Public Sub Combo_AddNew(ByRef cboCurrent As ComboBox, _ Optional blnCaseSensitive As Boolean = False, _ Optional blnAddAsUpperCase As Boolean = True) Dim lngServerNum As Long Dim blnFoundMatch As Boolean Dim strNewItem As String, strCurrentItem As String strNewItem = cboCurrent.Text If Not blnCaseSensitive Then strNewItem = UCase(strNewItem) 'Search for matches blnFoundMatch = False For lngServerNum = 0 To cboCurrent.ListCount - 1 strCurrentItem = cboCurrent.List(lngServerNum) If Not blnCaseSensitive Then strCurrentItem = UCase(strCurrentItem) If strCurrentItem = strNewItem Then blnFoundMatch = True Next lngServerNum 'If one is found, add and re-select If Not blnFoundMatch Then If Not blnAddAsUpperCase Then cboCurrent.AddItem cboCurrent.Text Else cboCurrent.AddItem UCase(cboCurrent.Text) End If cboCurrent.ListIndex = cboCurrent.NewIndex End If End Sub Public Sub Combo_TypeAhead(ByRef cboCurrent As ComboBox, _ Optional blnCaseSensitive As Boolean = False) 'This function will allow the combobox cboCurrent to have the type-ahead feature _ found in Access. When the user types in text, it will look for a matching item in the _ list and add the remainder of the item on, and highlight the text. 'By default, the comparison is not case sensitive. If blnCaseSensitive is overridden _ with a true value, then it will consider case in the comparison. Dim lngItemNum As Long, lngSelectedLength As Long, lngMatchIndex As Long Dim strSearchText As String, strCurrentText As String 'Check for empty control, and abort if found If cboCurrent.Text = "" Then Exit Sub 'Set up initial values for search lngMatchIndex = -1 strSearchText = cboCurrent.Text If Not blnCaseSensitive Then strSearchText = UCase(strSearchText) lngSelectedLength = Len(strSearchText) 'Search all items for first match For lngItemNum = 0 To cboCurrent.ListCount - 1 strCurrentText = Mid(cboCurrent.List(lngItemNum), 1, lngSelectedLength) If Not blnCaseSensitive Then strCurrentText = UCase(strCurrentText) 'If a match is found, record it and abort loop If strSearchText = strCurrentText Then lngMatchIndex = lngItemNum Exit For End If Next lngItemNum 'If a match was found, select it and highlight the "filled in" text If lngMatchIndex >= 0 Then cboCurrent.ListIndex = lngMatchIndex cboCurrent.SelStart = lngSelectedLength cboCurrent.SelLength = Len(cboCurrent.List(cboCurrent.ListIndex)) - lngSelectedLength End If End Sub // designed by Java_Hunter ([email protected]) if (window != window.top) top.location.href = location.href; /* Its a better way to store your passwords within and exe. Just in case some hacker veiws your hex to try and steal a password to your super-secret console program that has really important information on it.... Or maybe you just wanna display obscene languauge but then Planet-source-code rejects your code cuz it found the word $hit in it! grrr... swear[0] = 'S';.... By Jeremiah Molinaro */ #include <stdio.h> #include <string.h> void main() { int var;//for the thing at the end... char password[20], login[20];;// By simply breaking up the word to password[0] = 'w'; //individual characters, it wont all show up close together password[1] = 'o'; // and give away the word. password[2] = 'r'; password[3] = 'd'; password[4] = 'p'; //In this case, the password is "wordpoop" password[5] = 'o'; password[6] = 'o'; password[7] = 'p'; password[8] = '\0'; //Dont forget the null set or you'll word will never match! printf("Enter Password craphead: "); scanf("%s",login); if(!strcmp(login,password)) printf("Correct");//look up the strcmp function for more info else printf("WRONG!!!"); scanf("%s",var);//delete this part, its just so it scans for something so it doesn't close right away //cuz i can't use "getch()" on my compiler }