当我在VB.NET中编写此代码时,我有错误! = null这里有什么问题吗? [英] When I write this code in VB.NET I have error in ! = null whats the problem here any idea about that ?

查看:113
本文介绍了当我在VB.NET中编写此代码时,我有错误! = null这里有什么问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表示预期标识符





 Private Sub ComboBox2_KeyDown(ByVal sender) As System.Object,ByVal e As System.Windows.Forms.KeyEventArgs)处理TextBox8.KeyDown,TextBox6.KeyDown,TextBox5.KeyDown,TextBox3.KeyDown,TextBox2.KeyDown,DateTimePicker2.KeyDown,DateTimePicker1.KeyDown,ComboBox2.KeyDown 
If(e.KeyCode = Keys.Enter)然后

结束如果
if(Me .GetNextControl(ActiveControl,true)!= null)

e .Handled = True
Me.GetNextControl(ActiveControl,True).Focus()
结束如果





< b>我尝试过:



如何在TextBox上输入作为TAB按钮

解决方案

VB.NET 还没有!= 运算符,它改为<> 一个。例如,请参阅 VB.Net - 比较运算符 [ ^ ]。

此外它还没有 null ,请改用 Nothing



前往检查是否为空引用(请参阅 vb.net - 在VB中进行空检查 - 堆栈溢出 [ ^ ])

 如果  object   isNot   Nothing  然后 
' ...
结束 如果


It's Says Identifier Expected


Private Sub ComboBox2_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox8.KeyDown, TextBox6.KeyDown, TextBox5.KeyDown, TextBox3.KeyDown, TextBox2.KeyDown, DateTimePicker2.KeyDown, DateTimePicker1.KeyDown, ComboBox2.KeyDown
        If (e.KeyCode = Keys.Enter) Then

        End If
            if (Me .GetNextControl(ActiveControl, true)  != null)

            e.Handled = True
            Me.GetNextControl(ActiveControl, True).Focus()
        End If



What I have tried:

How to make Enter on a TextBox act as TAB button

解决方案

VB.NET has not != operator, it has instead the <> one. See, for instance VB.Net - Comparison Operators[^].
Also it doesn't have null, use Nothing instead.

The way to check for a null reference is (see vb.net - Null check in VB - Stack Overflow[^])

If object isNot Nothing then
  '...
End If


这篇关于当我在VB.NET中编写此代码时,我有错误! = null这里有什么问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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