搜索第二个列表框 [英] Searching second listbox

查看:61
本文介绍了搜索第二个列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'Project Name:              Ship With Us
'Project Purpose:           Input Zip Code and find the associated shipping cost
'Created/Revised by:        

Option Explicit On
Option Strict Off
Option Infer Off

Public Class MainForm

    Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'fills the list box with zip codes
        shippingoneListBox.Items.Add("60611")
        shippingoneListBox.Items.Add("60234")
        shippingoneListBox.Items.Add("56789")
        shippingoneListBox.Items.Add("23467")
        shippingoneListBox.Items.Add("60543")
        shippingoneListBox.Items.Add("60561")
        shippingoneListBox.Items.Add("55905")
        shippingoneListBox.Items.Add("89567")
        'fills the list box with second set of zip codes
        shippingtwoListBox.Items.Add("50978")
        shippingtwoListBox.Items.Add("78432")
        shippingtwoListBox.Items.Add("98432")
        shippingtwoListBox.Items.Add("97654")
        shippingtwoListBox.Items.Add("20245")
    End Sub

    Private Sub exitButton_Click(sender As Object, e As System.EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub

    Private Sub displayshipButton_Click(sender As Object, e As System.EventArgs) Handles displayshipButton.Click
        'determine whether a list box contains a specific zip code
        Dim id As String = String.Empty
        'if the user picks a zip code in ListBox1 then the shipping charge is $15.00
        'and if zip code is chose in  ListBox2  shipping charge is $20.00

        If (shippingoneListBox.FindString(zipTextBox.Text >= 0)) Then
            shippingLabel.Text = "Shipping is $15"
            shippingLabel.Show()
        ElseIf (shippingtwoListBox.FindString(zipTextBox.Text >= 0)) Then
            shippingLabel.Text = "Shipping is $20"
            shippingLabel.Show()
        Else
            shippingLabel.Text = "The zipcode was not found!"
            shippingLabel.Show()
        End If
    End Sub
End Class





输入列出的邮政编码时shippingtwoListBox它仍然会告诉我运费应该是15美元,而事实上它应该是20美元。我有没有编码错误的东西,它没有搜索第二个列表框?此外,当我输入一个没有添加到列表框的邮政编码时,标签没有显示找不到邮政编码!



任何帮助非常感谢!



When entering a zip code that is listed in "shippingtwoListBox" it will still tell me the shipping cost should be $15 when in fact it should be $20. Do I have something coded wrong that it isn''t searching the second list box? Also, when I enter a zip code that isn''t added to the listboxes the label isn''t displaying "The zipcode was not found!"

Any help would be much appreciated!

推荐答案

15.00
' 如果在ListBox2中选择了邮政编码,则运费是
15.00 'and if zip code is chose in ListBox2 shipping charge is


20.00

如果(shippingoneListBox.FindString(zipTextBox.Text> = 0 ))那么
shippingLabel.Text = 发货
20.00 If (shippingoneListBox.FindString(zipTextBox.Text >= 0)) Then shippingLabel.Text = "Shipping is


15
shippingLabel.Show()
ElseIf (shippingtwoListBox.FindString(zipTextBox.Text> = 0 ))然后
s hippingLabel.Text = 发货
15" shippingLabel.Show() ElseIf (shippingtwoListBox.FindString(zipTextBox.Text >= 0)) Then shippingLabel.Text = "Shipping is


这篇关于搜索第二个列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆