我有两个ListBox
控件的代码,我添加了指定整数(金额)的字符串,所以我想添加两个不同的ListBox
控件中的整数但是字符串也出现在标签中。
如何拒绝这些字符串?
Dim intWashandGo, intWashandDry, intWashDryandTyres, intWashDryandPolish As Integer
intWashandGo = 35
intWashandDry = 60
intWashDryandTyres = 70
intWashDryandPolish = 150
Me.ExteriorListBox.Items.Add("Wash and Go".ToString() & Format(intWashandGo, "currency"))
Me.ExteriorListBox.Items.Add("Wash and Dry".ToString() & Format(intWashandDry, "currency"))
Me.ExteriorListBox.Items.Add("Wash, Dry and Tyres".ToString() & Format(intWashDryandTyres, "currency"))
Me.ExteriorListBox.Items.Add("Wash, Dry, Tyres and Polish".ToString() & Format(intWashDryandPolish, "currency"))
Dim intNoWork, intVacuum, intValet As Integer
intNoWork = 0
intVacuum = 20
intValet = 200
Me.InteriorListBox.Items.Add("No Work".ToString() & Format(intNoWork, "currency"))
Me.InteriorListBox.Items.Add("Vacuum".ToString() & Format(intVacuum, "currency"))
Me.InteriorListBox.Items.Add("Valet".ToString() & Format(intValet, "currency"))
Private Sub CalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalcButton.Click
ExteriorLabel.Text = Format(ExteriorListBox.SelectedItem(), "currency")
InteriorLabel.Text = Format(InteriorListBox.SelectedItem(), "currency")
Me.TotalLabel.Text = Format(ExteriorLabel.Text + InteriorLabel.Text, "currency")
End Sub
答案 0 :(得分:0)
使用listbox.SelectedValue:
Dim intWashandGo, intWashandDry, intWashDryandTyres, intWashDryandPolish As Integer
intWashandGo = 35
intWashandDry = 60
intWashDryandTyres = 70
intWashDryandPolish = 150
Me.ExteriorListBox.Items.Add(Format(intWashandGo, "currency"))
Me.ExteriorListBox.Items(Me.ExteriorListBox.Items.Count - 1).Selectedvalue = intWashandGo
Me.ExteriorListBox.Items.Add(Format(intWashandDry, "currency"))
Me.ExteriorListBox.Items(Me.ExteriorListBox.Items.Count - 1).Selectedvalue = intWashandDry
Me.ExteriorListBox.Items.Add(Format(intWashDryandTyres, "currency"))
Me.ExteriorListBox.Items(Me.ExteriorListBox.Items.Count - 1).Selectedvalue = intWashDryandTyres
Me.ExteriorListBox.Items.Add(Format(intWashDryandPolish, "currency"))
Me.ExteriorListBox.Items(Me.ExteriorListBox.Items.Count - 1).Selectedvalue = intWashDryandPolish
Debug.WriteLine(Me.ExteriorListBox.SelectedValue)
Dim intNoWork, intVacuum, intValet As Integer
intNoWork = 0
intVacuum = 20
intValet = 200
Me.InteriorListBox.Items.Add(Format(intNoWork, "currency"))
Me.InteriorListBox.Items(Me.InteriorListBox.Items.Count - 1).SelectedValue = intNoWork
Me.InteriorListBox.Items.Add(Format(intVacuum, "currency"))
Me.InteriorListBox.Items(Me.InteriorListBox.Items.Count - 1).SelectedValue = intVacuum
Me.InteriorListBox.Items.Add(Format(intValet, "currency"))
Me.InteriorListBox.Items(Me.InteriorListBox.Items.Count - 1).SelectedValue = intValet
Debug.WriteLine(Me.InteriorListBox.SelectedValue)
End Sub
Private Sub CalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalcButton.Click
Dim intTotal As Integer
Dim intExterior As Integer
Dim intInterior As Integer
intExterior = val(Me.ExteriorListBox.SelectedValue)
intInterior = val(Me.InteriorListBox.SelectedItem)
intTotal = intExterior + intInterior
Me.ExteriorLabel.Text = Format(intExterior, "currency")
Me.InteriorLabel.Text = Format(intInterior, "currency")
Me.TotalLabel.Text = ("Your total work is".ToString & Format(intTotal, "currency"))
Me.ClearButton.Focus()
End Sub
Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
Me.ExteriorLabel.Text = ""
Me.InteriorLabel.Text = ""
Me.TotalLabel.Text = ""
End Sub
Private Sub ExitButton_Click(sender As Object, e As EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
答案 1 :(得分:0)
Dim intWashandGo, intWashandDry, intWashDryandTyres, intWashDryandPolish As Integer
intWashandGo = 35
intWashandDry = 60
intWashDryandTyres = 70
intWashDryandPolish = 150
Me.ExteriorListBox.Items.Add(Format(intWashandGo, "currency"))
Me.ExteriorListBox.Items.Add(Format(intWashandDry, "currency"))
Me.ExteriorListBox.Items.Add(Format(intWashDryandTyres, "currency"))
Me.ExteriorListBox.Items.Add(Format(intWashDryandPolish, "currency"))
Debug.WriteLine(Me.ExteriorListBox.SelectedItem)
Dim intNoWork, intVacuum, intValet As Integer
intNoWork = 0
intVacuum = 20
intValet = 200
Me.InteriorListBox.Items.Add(Format(intNoWork, "currency"))
Me.InteriorListBox.Items.Add(Format(intVacuum, "currency"))
Me.InteriorListBox.Items.Add(Format(intValet, "currency"))
Debug.WriteLine(Me.InteriorListBox.SelectedItem)
End Sub
Private Sub CalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CalcButton.Click
Dim intTotal As Integer
Dim intExterior As Integer
Dim intInterior As Integer
intExterior = Me.ExteriorListBox.SelectedItem()
intInterior = Me.InteriorListBox.SelectedItem()
intTotal = intExterior + intInterior
Me.ExteriorLabel.Text = Format(intExterior, "currency")
Me.InteriorLabel.Text = Format(intInterior, "currency")
Me.TotalLabel.Text = ("Your total work is".ToString & Format(intTotal, "currency"))
Me.ClearButton.Focus()
End Sub
Private Sub ClearButton_Click(sender As Object, e As EventArgs) Handles ClearButton.Click
Me.ExteriorLabel.Text = ""
Me.InteriorLabel.Text = ""
Me.TotalLabel.Text = ""
End Sub
Private Sub ExitButton_Click(sender As Object, e As EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
结束班