HTA Prompt / VB Code - 试图显示2个下拉菜单

时间:2014-07-09 15:09:35

标签: vb.net hta

我有一个使用VB代码的HTA提示。我需要在桌子上显示两个下拉菜单。出于某种原因,只有第二个下拉列表出现在“选择部门”中。当只有一个下拉列表时它工作正常,但当我为扇区添加第二个时,它删除了第一个位置。如何让两个下拉列表显示出来,如下所示:

选择您当前的位置:[DROPDOWN]

选择您的行业:[DROPDOWN]

    'AA Sites
Function startSTAGE3()
    ON ERROR RESUME NEXT
    LASTSTAGE = STAGE   
    bodystring = "<br>Select your current location: <SELECT SIZE='.5' NAME='Clocation' ONCHANGE='LOCCHANGED()'>"
    bodystring = bodystring & "<option value='0'>&nbsp;</option>"
    bodystring = bodystring & "<option value='MacDill AFB, FL, APO, AA'"
    If locationindex = 1 Then bodystring = bodystring & " selected"
    bodystring = bodystring & ">MacDill AFB, FL, APO, AA</option></SELECT>"
    bodystring = "<br><br><br>Select your sector: <SELECT SIZE='.3' NAME='Csector' ONCHANGE='SECTORCHANGED()'>"
    bodystring = bodystring & "<option value='0'>&nbsp;</option>"
    bodystring = bodystring & "<option value='ES'"
    If sectorindex = 1 Then bodystring = bodystring & " selected"
    bodystring = bodystring & ">ES</option><option value='L&A'"
    If sectorindex = 2 Then bodystring = bodystring & " selected"
    bodystring = bodystring & ">L&A</option><option value='I&S'"
    If sectorindex = 3 Then bodystring = bodystring & " selected"
    bodystring = bodystring & ">I&S</option><option value='S2'"
    If sectorindex = 4 Then bodystring = bodystring & " selected"
    bodystring = bodystring & ">S2</option><option value='INC'"
    If sectorindex = 5 Then bodystring = bodystring & " selected"
    bodystring = bodystring & ">INC</option></SELECT>"

    Function SECTORCHANGED()
        ON ERROR RESUME NEXT
        currentsector = Csector(Csector.selectedIndex).Value
        sectorindex = Csector.selectedIndex
    End Function

    Function LOCCHANGED()
        ON ERROR RESUME NEXT
        currentlocation = Clocation(Clocation.selectedIndex).Value
        locationindex = Clocation.selectedIndex
    End Function

1 个答案:

答案 0 :(得分:0)

首先,您错过了第一个功能的End Function

第二次,而不是使用:

bodystring = bodystring & [...]

我宁愿建议:

bodystring += [...]

更容易阅读和聚类,而不是代码。

第三次,您在此处使用之前会覆盖bodystring

bodystring = bodystring & ">MacDill AFB, FL, APO, AA</option></SELECT>"
'The next commands overwrites bodystring before it is being used
bodystring = "<br><br><br>Select your sector: <SELECT SIZE='.3' NAME='Csector' ONCHANGE='SECTORCHANGED()'>"
bodystring = bodystring & "<option value='0'>&nbsp;</option>"
bodystring = bodystring & "<option value='ES'"

这可能是错误。

EDIT1

我也建议使用

If [condition] then
'[stuff to do]
ElseIf [condition] then
'[stuff to do]
ElseIf [condition] then
'[stuff to do]
End If

而不是内联If s。