【问题标题】:Function call on left hand side of assignment must return Variant or object赋值左侧的函数调用必须返回 Variant 或对象
【发布时间】:2020-08-21 12:06:09
【问题描述】:
Private Sub CommandButton1_Click()

If TextBox1 = Hayu And TextBox2 = 2007 Then

MsgBox = "login successful"

Me.Hide

Else

MsgBox = "incorrect creditanls"

End If

End Sub

【问题讨论】:

  • 你想调用函数MsgBox所以删除=,你不能给函数赋值:MsgBox "login successful"
  • 你是否编辑了对MsgBox的两个调用?

标签: excel vba


【解决方案1】:

这样效果更好吗:

Private Sub CommandButton1_Click()
    If TextBox1 = "Hayu" And TextBox2 = "2007" Then
        MsgBox "login successful"
        Me.Hide
    Else
        MsgBox "incorrect creditanls"
    End If
End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-23
    • 2014-11-15
    • 1970-01-01
    • 2013-04-15
    • 2012-06-29
    • 2012-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多