语法错误:'I'运算符VB.NET后缺少操作数 [英] Syntax error: missing operand after 'I' operator VB.NET
问题描述
Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
Dim DV As New DataView(ED_dataDataSet27.Users)
DV.RowFilter = String.Format("User name Like '%{0}%'", TextBox6.Text)
DataGridView3.DataSource = DV
End Sub
我的尝试:
我试图改为|DV.RowFilter = String.F ormat(Password Like'%{0}%',TextBox6.Text)|它工作,但当我从密码更改为用户名时,出现此错误语法错误:'i'运算符vb.net后缺少操作数|
What I have tried:
I tried to change to |" DV.RowFilter = String.Format("Password Like '%{0}%'", TextBox6.Text) " | and it worked but when I change from Password to User name, this error come up | "Syntax error: Missing operand after 'i' operator vb.net" |
推荐答案
这是你名字中的空格。
试一试:
It's the space in your name.
Try this:
DV.RowFilter = String.Format("[User name] Like '%{0}%'", TextBox6.Text)
顺便说一句:帮自己一个忙,并停止使用Visual Studio默认名称 - 你可能还记得今天的TextBox6是用户名,但是当你必须在三周内修改它时,你会这样做吗?使用描述性名称 - 例如tbUserName - 您的代码变得更容易阅读,更自我记录,更易于维护 - 并且编码速度更快,因为Intellisense可以在三次击键中转到tbUserName,其中TextBox6需要思考大概和8次击键......
BTW: Do yourself a favour, and stop using Visual Studio default names for everything - you may remember that "TextBox6" is the user name today, but when you have to modify it in three weeks time, will you then? Use descriptive names - "tbUserName" for example - and your code becomes easier to read, more self documenting, easier to maintain - and surprisingly quicker to code because Intellisense can get to to "tbUserName" in three keystrokes, where "TextBox6" takes thinking about and 8 keystrokes...
这篇关于语法错误:'I'运算符VB.NET后缺少操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!