有人告诉我。在vb.net中有什么(焦点)代码? [英] Anybody Tell Me.What is the (Focus) code in vb.net?

查看:356
本文介绍了有人告诉我。在vb.net中有什么(焦点)代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人告诉我。什么是vb.net中的(焦点)代码?我想知道Vb.net中的(焦点)代码的含义。请帮帮我?

Anybody Tell Me.What is the (Focus) code in vb.net?i want to know about meaning of (Focus) Code in Vb.net.Please Help Me?

推荐答案

单词Focus意味着特定控件(例如文本框)是焦点或不焦点。当用户点击像文本框这样的控件中的/时,该控件将从用户获得所有输入(通过键盘)。当用户按下键盘上的TAB按钮时,就像我们一直在互联网或桌面应用程序中填写表格一样,FOCUS从一个控件移动到下一个控件。 textbox.focus方法只是为我们编程。假设您已经在VB.NET中创建了一个桌面应用程序,用户可以在其中注册自己,并且在填写表单时他/她不小心忘记输入他/她的电子邮件地址并单击提交按钮,您将如何处理通知他/她。以下代码将执行...



The word "Focus" means that a particular control (e.g. a textbox) is in focus or not. When a user clicks on/in a control like textbox then this control gets all the input (through the keyboard) from the user. When a user presses the TAB button on the keyboard like we do all the time filling up the forms on the internet or in a desktop application the FOCUS moves from one control to the next one. The textbox.focus methos simply does this programatically for us. Suppose you've created a desktop application in VB.NET in which the user can register itself, and when filling up the form he/she accidentally forgets to enter his/her email address and clicks on the submit button, what will you do to notify him/her about that. The following code will do...

Private Sub btnSubmit_Click(object as sender, e as EventArgs) handles btnSubmit.clik
if txtEmail.text.trim.lenght=0 then
msgbox("Please enter your email address and try again.")
txtEmail.Focus()
exit sub
end if
'rest of the validation goes here
End Sub




现在
在上面的代码中,我们检查了用户提供的电子邮件地址的长度,如果长度为0,我们通过MsgBox向用户发出警告,txtEmail.Focus将自动激活用户的txtEmail文本框。 br />


希望这会有所帮助。



now in the above code we've checked the lenght of the email address the user has provided and if the length is 0 the we've alerted the user via the MsgBox and the txtEmail.Focus will activate the txtEmail textbox for the user automatically.

Hope this will help.


这篇关于有人告诉我。在vb.net中有什么(焦点)代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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