2014-11-02 70 views
1

我一直在用一些IF语句一遍又一遍地遇到同样的问题。一个形式我得到了这个:VB.net如果跨越不同表格的声明不起作用

If KarlConvo = 4 Then 
    MsgBox("Karl: Wow man. I overheard everything. I don't like your methods but it did work. Have this man. I can't wait until she approaches my sexy self") 
    MsgBox("You have obtained the SANDWICH") 
    PlayerProfileMale.tpbSandwich.Visible = True 
    PlayerProfileMale.lblSandwich.Visible = True 
    Form2.lblFact3C2.Visible = True 
    KarlConvo = 5 
    TobyConvo = 4 
    PlayerProfileMale.EatButton = True 
End If 

上面的代码发生在msgbox弹出后。它应该允许在另一个表单上出现“吃”按钮。该表格上的IF语句:

If EatButton = True Then 
    btnEat.Visible = True 
End If 

那么问题是,按钮是不是我的第二个表上显示,即使它有唯一的条件是为EatButton变量(这是一个公共属性)是真正。任何想法为什么发生这种情况?

在此先感谢

+0

我不清楚EatButton的范围。显示更多的上下文? – 2014-11-02 18:01:17

+0

尝试先看4行。该线与EatButton有什么区别? – Steve 2014-11-02 18:05:28

+0

要从另一个表单显示PlayerProfileMale表单中的btnEat按钮,必须执行PlayerProfileMale.btnEat.Show – 2014-11-02 18:30:37

回答

1

这里有几件事情要检查:

  1. 显示,涂料,或重新加载PlayerProfileMale形式分配PlayerProfileMale.EatButton = True后。触发导致If EatButton语句执行的事件。

  2. 确定您在为PlayerProfileMale.EatButton = True指定PlayerProfileMale的正确实例。这通常不会成为问题,但可以是创建表单实例并在创建任务时创建(或已经打开)另一个实例。