Results 1 to 12 of 12

Thread: [RESOLVED] combobox help!

  1. #1

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Resolved [RESOLVED] combobox help!

    Hy I need for my program a combobox but i don`t know how to use it. How to add intems like Page1 Page2 etc.. and how to set it up for address on click

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: combobox help!

    You can do it in a loop:
    Code:
    Dim lngN As Long
        For lngN = 1 To 100 'or To whatever
            Combo1.AddItem "Page" & lngN
        Next lngN
    Or:
    Code:
    Combo1.AddItem "Page1"
    Combo1.AddItem "Page2"
    Combo1.AddItem "Page3"
    '...
    What do you mean with 'set it up for address on click'?

  3. #3

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: combobox help!

    like a button for example web.navigate "http://google.com" How i put this to the combo?

  4. #4

  5. #5

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: combobox help!

    if i say web.navagate "http://google.com" this mean that in my program in web .. but this is just a example

  6. #6
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: combobox help!

    Sorry, miss-noticed that
    Code:
    Option Explicit
    
    Private Sub Combo1_Click()
        WebBrowser1.Navigate Trim(Combo1.List(Combo1.ListIndex))
    End Sub
    
    Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then
            Call Combo1_Click
        End If
    End Sub
    ?

  7. #7

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: combobox help!

    yes something like this .. But for example the url is long .. and in combox i want to be a short name ..

  8. #8

  9. #9

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: combobox help!

    i mean like a hiperlink .. name is Test and link is web.navigate "http://goooooooooooooooogle.com" In combo to appear "test" and whet i press it to go to that link web.navigate "http://goooooooooooooogle.com" It is posible ?

  10. #10
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: combobox help!

    You can use Type and an array of some Type:
    Code:
    Option Explicit
    
    Private Type URL
        strName As String
        strURL As String
    End Type
    
    Private x(1 To 2) As URL 'expand this...
    
    Private Sub Form_Load()
        Dim lngN As Long
    
        x(1).strName = "Google"
        x(1).strURL = "http://www.google.com"
        x(2).strName = "Yahoo"
        x(2).strURL = "http://www.yahoo.com"
        'and this...
        
        For lngN = LBound(x) To UBound(x)
            Combo1.AddItem x(lngN).strName
        Next lngN
    End Sub
    
    Private Sub Combo1_Click()
        Dim lngN As Long
        
        For lngN = LBound(x) To UBound(x)
            If x(lngN).strName = Combo1.List(Combo1.ListIndex) Then
                WebBrowser1.Navigate x(lngN).strURL
                    Exit Sub
            End If
        Next lngN
    End Sub

  11. #11

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Thumbs up Re: combobox help!

    just grate ! thanks a lot !

  12. #12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width