1

我有一个 Html 表单,上面有下拉控件。我想从 VB6.0 表单中选择组合框文本,并且这个组合框文本分配给 html 下拉列表,那么我该怎么做呢?

我的 vb6.0 具有与 html 表单相同的控件。

例如我的 html 代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test Application</title>    
</head>
<body>

  Title : <select name="ddlTitle" id="ddlTitle" style="width: 70px;">
    <option value="Mr.">Mr.</option>
    <option value="Mrs.">Mrs.</option>
    <option value="Baba">Baba</option>
    <option value="Baby">Baby</option>
</select><br />
</body>
</html>

对于 vb6.0,我尝试使用此代码,我得到一个下拉 ID,但我想从 vb6.0 组合框中将值分配给 html 下拉框

    Dim HTMLI As HTMLInputElement

For Each HTMLI In TargetIE.Document.getElementsByTagName("select")
        Select Case HTMLI.id
            Case "ddlTitle"
            Dim i  As Integer
            For i = 0 To Combo1.ListCount
            If Combo1.ListIndex = HTMLI.Item(i).index Then
                HTMLI.Item(i).Value = Combo1.Text
                Exit For
            End If
            Next
        End Select
    Next HTMLI

在使用这个 HTMLI.Value 时,它​​给了我一个错误 Object doesn't support this property or method。所以我需要尝试的不是价值..所以vb6.0组合值被分配给Html下拉

4

2 回答 2

0

您将要使用nodeValue而不是Value. 所以:

HTMLI.Item(i).Value = Combo1.Text

应该:

HTMLI.Item(i).nodeValue = Combo1.Text
于 2013-08-26T12:57:07.610 回答
0

我解决了这个问题,我使用Selected 而不是Value

HTMLI.Item(i).Selected = True
OR
HTMLI.Item(i).Selected = Combo1.Text
于 2013-08-27T05:58:38.037 回答