1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Option Compare Database
Const strHTML As String = "blablabla<select name='machin' size='10' multiple>" & _
"<option value='1'>Test1</option>" & _
"<option value='2'>Test2</option>" & _
"<option value='3'>Test3</option>" & _
"</select></form></body></html>"
Type Itemz
Value As String
id As String
End Type
Type BlocSelect
count As Long
item() As Itemz
header As String
name As String
content As String
End Type
Sub GetHTMLList(ByVal str As String)
Dim Bloc As BlocSelect
Dim i As Long
Dim s() As String
Dim it() As Itemz
str = strHTML
Bloc.header = "<select" & Split(Split(str, "<select")(1), ">")(0) & ">"
Bloc.name = Split(Split(Bloc.header, "name='")(1), "'")(0)
Bloc.content = Split(Split(str, Bloc.header)(1), "</select>")(0)
s = Split(Bloc.content, "<option")
ReDim it(UBound(s))
Bloc.count = UBound(s)
For i = 1 To UBound(s)
it(i).id = Split(Split(s(i), "value='")(1), "'>")(0)
it(i).Value = Split(Split(s(i), ">")(1), "</option")(0)
Next i
Bloc.item = it
Debug.Print Bloc.name
Debug.Print Bloc.count
For i = 1 To Bloc.count
Debug.Print , Bloc.item(i).id, Bloc.item(i).Value
Next i
End Sub |
Partager