Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropCombo Box question

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
US
hi,

i'm trying to list a range (PartNo) from Excel into a DropCombo Box.So far I'm only able to list only one cell in the range.
how do i enumerate the range so that it will appear correctly in the DropCombo Box?

thanks
zach

Code:
Declare Function DisplayChoice(szLocale$) As String
                               
Sub Main
Dim szLocation$
Dim iDone%
Dim DroplistBox as string

Dim xlApp As Object, xlWB As Object, xlSheet As Object
Dim xlFile As String, i As Long
xlFile = "C:\Test2.xls"
Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open(xlFile)
xlApp.visible = true
Set xlSheet = xlWB.Sheets("sheet1")

For i = 2 to 13
CurrPartNo = xlSheet.Range ("A1")
PartNo = xlSheet.Range ("C" & i)   'this is where i need help


Next



           Begin Dialog Proc 0, 1, 175, 93, "Please Select"
           ButtonGroup .ButtonPressed                   
           OkButton  100, 55, 50, 14
           CancelButton  100, 15, 50, 14
           PushButton   100, 35, 50, 14, "&Reset", .btnReset
           Text  12, 10, 62, 9, "Available Sessions"
           Text  12, 18, 82, 9, "Click on down arrow"
           Text  12, 25, 62, 9, "and select"
           Text  12, 58, 82, 9, "CurrPartNo is" 
           Text  12, 68, 82, 9, CurrPartNo
           DropComboBox 10, 35,65,55, PartNo, .dcbSessions  'help here as well
           End Dialog

           iDone = FALSE

    While (iDone = FALSE)    
        Dim dMain as Proc
        nRet = Dialog(dMain) 
      
        Select Case nRet
        
            Case -1                       ' -1 is returned if the user chose OK

                iDone = TRUE
                szLocation = dMain.dcbSessions
           
        If SzLocation = "" Then
        MsgBox "You Didn't Select a Session. Please Start Over"
        Exit Sub
        End If

                
            Case 0                        ' 0 is returned if the user chose Cancel
                iDone = TRUE
            'msgbox "Please select a Session"    
            
            Case 1                        ' 1 is returned if the user chose Reset
                dMain.dcbSessions = ""
               
            Case Else
                msgbox "Some undefined button pressed " + str(dMain.ButtonPressed)
                
        End Select
    Wend
    
xlApp.DisplayAlerts = False
xlWB.Save
xlWB.Close
      
Set xlSheet = Nothing
Set xlWB = Nothing
Set xlApp = Nothing


End Sub

'--------------------------------------------------------------------------------
Function DisplayChoice(szLocale$) As String

szResult = szLocale

DisplayChoice = szResult
 
hi,

is what i'm requesting not doable?

thanks
zach
 
hi,
figured it out (whew!)through trial & error from an old post by MrMilson. (Thanks MrMilson!). still trying to understand arrays.
here's what i added/changed:
Code:
[blue]Dim PartNo() as string[/blue]
[blue]Dim count as integer[/blue]

For i = 2 To 13 
CurrPartNo = xlSheet.Range("A1")
[blue]count = count + 1/blue]
[blue]redim preserve PartNo(count)[/blue]
PartNo[blue](count)[/blue] = xlSheet.Range ("C" & i)   

Next

           Begin Dialog Proc 0, 1, 175, 93, "Please Select"
           ButtonGroup .ButtonPressed                   
           OkButton  100, 55, 50, 14
           CancelButton  100, 15, 50, 14
           PushButton   100, 35, 50, 14, "&Reset", .btnReset
           Text  12, 10, 62, 9, "Available Sessions"
           Text  12, 18, 82, 9, "Click on down arrow"
           Text  12, 25, 62, 9, "and select"
           Text  12, 58, 82, 9, "CurrPartNo is" 
           Text  12, 68, 82, 9, CurrPartNo
           DropComboBox 10, 35,65,55, PartNo[blue]()[/blue], .dcbSessions
           End Dialog


thanks again
zach
 



I hope that you gave Mr Milson a little purple STAR.

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top