如何在搜索按钮中放置消息框 [英] How to put messagge box in search button

查看:96
本文介绍了如何在搜索按钮中放置消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai,我需要在这里提供建议和帮助,在此程序中,我使用1个按钮(我将其命名为btnsearch)和1个文本框(我将其命名为textboxname).此按钮的功能用于在数据库中搜索数据以及文本框用于用户填写名称.我想在此处放置消息框,如果在我的代码中未找到名称未找到".原因是通知用户其在数据库中找不到的名称.任何建议我如何更正我的代码以解决此问题.这是我的代码.我正在使用Visual Studio 2005& sql 2005作为数据库.

Hai ,i need advice and help here,In this programme i use 1 button( i name it btnsearch) and 1 textbox(i named it textboxname).The function of this button is use to search data in database and function of textbox is for user fill name.I want to put messagge box which if "Name is not found" in my code here.The reason is to inform to user that the name which their find in not in database.Any advice how i able to correct my code to solve this issue. Here is my code.I am using visual studio 2005 & sql 2005 as database .

Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsearch.Click
        Me.StaffBindingSource.Filter = "NAME =  '" & Me.txtsearch.Text & "'"

    End Sub

推荐答案

这样的事情?

Something like this?

dim prevFilter as string=Me.StaffBindingSource.Filter
Me.StaffBindingSource.Filter = "NAME =  '" & Me.txtsearch.Text & "'"

if Me.StaffBindingSource.count = 0 then
   msgbox ("Name is not found")
   'If the name is not found
   'Set the filter back to wath it was
   Me.StaffBindingSource.Filter= prevFilter
end if


这篇关于如何在搜索按钮中放置消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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