如果是vB.NET中的else语句 [英] If else statement in vB.NET

查看:54
本文介绍了如果是vB.NET中的else语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我知道它必须如此简单,但我遗漏了一些我无法弄清楚的傻​​事。

所以这里我有Txtbox1和FromDate和ToDate的搜索按钮



要填写Txtbox1,要填写FromDate和ToDate(两个日期)。然后只有搜索代码应继续并显示结果。否则它应该弹出说输入搜索条件。



如果这个愚蠢的逻辑在VB.NET中有其他的话可以帮助我吗?




从评论中移出



Hello,

I know it must so simple but I am missing something silly which I couldn't figure out.
So Here I have search button with Txtbox1 and FromDate and ToDate

Either Txtbox1 should be filled or FromDate and ToDate (both dates) should be filled. Then only Search code should proceed and display the result. Otherwise it should pop up saying enter search criteria.

Can anyone here help me if this silly logic with if else in VB.NET?


Moved from comment

If Not (txtSInvoice IsNot String.Empty) Or Not (txtFromDate IsNot String.Empty AndAlso txtToDate IsNot String.Empty) Then

ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", "Hello Search", True)
Else
ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", "Please enter Criteria for Search", True)

End If



我试过这个,但它不起作用。我不知道VB。但是在C#中你做了你所说的txt1或(frmDate和Todate)


I tried this but it doesn't work. I don't know about VB. But in C# it does what you said "txt1 or (frmDate and Todate)"

推荐答案

引用:

它应该弹出





这是你的用户想要的吗?我不愿意。





最好让搜索按钮被禁用,直到输入条件为止。



我对你正在做的事情不太熟悉,但是如下所示:

searchbutton.Enabled = Txtbox1.Length> 0或(FromDate ...和ToDate ...)


嘿,不要偷懒!试一试: If ... Then ... Else Statement(Visual Basic) [ ^ ]



伪代码:

Hey, don't be lazy! Try it: If...Then...Else Statement (Visual Basic)[^]

In pseudo-code:
If TextBox is not empty then
   Procceed
Else
   DisplayMessage
End If


hi sudevsu,

Marciej有一个好点,你应该单步执行代码并测试值独立,以便你对如何正确使用布尔运算符有一个好主意(提示 - 首先不是问题)。



regs ron O。
hi sudevsu,
Marciej has a good point, you should step through your code and test the values independently so that you get a good idea on how to use Boolean operators correctly (Hint - first NOT is a problem).

regs ron O.


这篇关于如果是vB.NET中的else语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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