在vb.net中将文本框文本与列表框项目文本进行比较 [英] Comparing text box text with listbox items text in vb.NET
本文介绍了在vb.net中将文本框文本与列表框项目文本进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在vb.NET中将文本框文本与列表框项目文本进行比较....请帮助
how to Compare text box text with listbox items text in vb.NET....Please HELP
推荐答案
我在VB.net中尝试了以下操作效果很好
i tried the following in VB.net it worked fine
aspx页面
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
</div>
<asp:ListBox ID="ListBox1" runat="server">
<asp:ListItem>zero</asp:ListItem>
<asp:ListItem>first</asp:ListItem>
<asp:ListItem>second</asp:ListItem>
</asp:ListBox>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
背后的代码
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each item In ListBox1.Items
If item.ToString = TextBox1.Text Then
Response.Write("matching " + item.ToString)
End If
Next
End Sub
结束班级
这篇关于在vb.net中将文本框文本与列表框项目文本进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文