Max, nice idea.
However, since I already had the following implementation ready to post, I'll do that too. Thought of this more as a fun challenge
Here we are going to do most stuff by API. We will avoid the Unicode to ANSI conversion for each string added to the combobox and by also including the WM_SETREDRAW message, this screams
The loops are using ASCII values of 0 thru 9, vs decimal values of 0 thru 9Code:Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long Private Const WM_SETREDRAW As Long = &HB Private Const CB_ADDSTRING As Long = &H143 Private Sub Form_Load() Dim intN As Integer Dim intM As Integer Dim arrItems(0 To 4) As Byte Dim intO As Integer Dim sPtr As Long sPtr = VarPtr(arrItems(0)) For intN = 0 To 31 Combo1(intN).Clear Erase arrItems() SendMessage Combo1(intN).hWnd, WM_SETREDRAW, 0&, ByVal 0& ' do 1-9 For intM = 49 To 57 ' 1-9 arrItems(0) = intM SendMessage Combo1(intN).hWnd, CB_ADDSTRING, 0&, ByVal sPtr Next ' do 10-99 For intO = 49 To 57 arrItems(0) = intO ' tens For intM = 48 To 57 ' 0-9 arrItems(1) = intM SendMessage Combo1(intN).hWnd, CB_ADDSTRING, 0&, ByVal sPtr Next Next ' do 100-199 arrItems(0) = 49 ' 100 place For intO = 48 To 57 ' 0-9 tens arrItems(1) = intO For intM = 48 To 57 ' 0-9 arrItems(2) = intM SendMessage Combo1(intN).hWnd, CB_ADDSTRING, 0&, ByVal sPtr Next Next ' do 200-249 arrItems(0) = 50 ' 200 place For intO = 48 To 52 ' 0-4 tens arrItems(1) = intO For intM = 48 To 57 ' 0-9 arrItems(2) = intM SendMessage Combo1(intN).hWnd, CB_ADDSTRING, 0&, ByVal sPtr Next Next ' do 250-256 arrItems(1) = 53 ' 50 place For intM = 48 To 54 ' 0-6 arrItems(2) = intM SendMessage Combo1(intN).hWnd, CB_ADDSTRING, 0&, ByVal sPtr Next Combo1(intN).ListIndex = 0 SendMessage Combo1(intN).hWnd, WM_SETREDRAW, 1&, ByVal 0& Next End Sub




Reply With Quote