这是我在Visual Basic窗体表单应用程序中创建的程序,它使用两个列表框,一个用于Months,另一个用于Birthstones。当用户单击Birthstone时,lblDescription控件中会显示相应的月份,或者当用户单击_strMonths列表框中的Month时,lblDescription中会显示相应的Birthstone。该程序正在运行,但我不小心删除了它,现在我不再记得确切的代码了。我现在已经花了一个星期重新创建它,但无济于事。我已经研究过SelectedIndex属性,但到目前为止我所看到的一切都是关于SelectedIndex属性是一个整数,但我的是一个字符串。所以我来论坛寻求帮助。代码很简单。我添加了一个MsgBox(_intFill),它显示了所有的诞生石。我几乎在那里,但还没有雪茄。
<servlet>
<servlet-name>DBbuildServletDispatcher</servlet-name>
<servlet-class>com.foo.DBbuildServletDispatcher</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet>
<servlet-name>AppServletDispatcher</servlet-name>
<servlet-class>com.foo.AppServletDispatcher</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
答案 0 :(得分:0)
Option Strict On
Public Class frmBirthstones
Private _strStones(11) As String
Private _strMonths(11) As String
Private Sub frmBirthstones_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'Array items for Brith Stones
_strStones(0) = "Garnet"
_strStones(1) = "Amethyst"
_strStones(2) = "Aquamarine"
_strStones(3) = "Diamond"
_strStones(4) = "Emerald"
_strStones(5) = "Pearl"
_strStones(6) = "Ruby"
_strStones(7) = "Peridot"
_strStones(8) = "Sapphire"
_strStones(9) = "Opal"
_strStones(10) = "Topaz"
_strStones(11) = "Turquoise"
'Array items for Months
_strMonths(0) = "January"
_strMonths(1) = "February"
_strMonths(2) = "March"
_strMonths(3) = "April"
_strMonths(4) = "May"
_strMonths(5) = "June"
_strMonths(6) = "July"
_strMonths(7) = "August"
_strMonths(8) = "September"
_strMonths(9) = "October"
_strMonths(10) = "November"
_strMonths(11) = "December"
'Makes label Description visible
lblDescription.Visible = True
'fills listbox with Birthstones
lstStones.Items.AddRange(_strStones)
'fills listbox with Months
lstMonths.Items.AddRange(_strMonths)
End Sub
Private Sub lstStones_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lstStones.SelectedIndexChanged
lblDescription.Text = _strStones(lstStones.SelectedIndex).ToString() & " is the Birthstone for the month of " & _strMonths(lstStones.SelectedIndex).ToString()
End Sub
Private Sub lstMonths_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lstMonths.SelectedIndexChanged
lblDescription.Text = _strMonths(lstMonths.SelectedIndex).ToString() & " is the Month for the Birthstone " & _strStones(lstMonths.SelectedIndex).ToString()
End Sub
End Class
也许这就是你想要做的。