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
Printable View
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
You can do it in a loop:Or:Code:Dim lngN As Long
For lngN = 1 To 100 'or To whatever
Combo1.AddItem "Page" & lngN
Next lngN
What do you mean with 'set it up for address on click'?Code:Combo1.AddItem "Page1"
Combo1.AddItem "Page2"
Combo1.AddItem "Page3"
'...
like a button for example web.navigate "http://google.com" How i put this to the combo?
Do you want it to navigate in your or external app (browser)?
if i say web.navagate "http://google.com" this mean that in my program in web .. but this is just a example
Sorry, miss-noticed that :blush:?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
yes something like this .. But for example the url is long .. and in combox i want to be a short name ..
Short name? How does it look like? Do you mean... the title? :confused:
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 ?
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
just grate ! thanks a lot !
You're welcome :wave: