如何返回上一个表单 [英] How to go back to a previous form

查看:160
本文介绍了如何返回上一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要从StaffAccountView转到房间预订。我怎么能这样做?我查看过很多不同的帖子,但找不到任何可行的帖子。我是否必须创建全局变量?我已经从帖子中尝试了这个,但似乎没有用。任何人都可以帮忙吗?



If I was to go from StaffAccountView to Room Booking. How would I be able to do this? I have looked at many different posts but cannot find anything that will work. Do I have to create a Global Variable? I've tried this from posts but it doesn't seem to work. Can anyone help?

Dim ExitedForm as Form





在退出按钮





In the exit button

ExitedForm=Me 
StaffAccountView.Show 
me.hide





后退按钮





On the Back Button

ExitedForm.show





我希望按钮能够返回上一个表格,即StaffAccountView



我尝试过的事情:



我已经尝试过上面的代码,但是因为它公开仍然没有成功t分享表格



I want the button to be able to go back to the previous form which is StaffAccountView

What I have tried:

I have tried the code above but it does not work since making it public still won't share across a form

推荐答案

嗨会员13209355,



我假设您的第一个表格名称是 StaffAccountViewForm ,第二个表单名称为 RoomBookingForm



您需要将 StaffAccountViewForm 实例作为参数传递给 RoomBookingForm 的构造函数。在构造函数中,将表单实例保存到 RoomBookingForm 的局部变量中。所以以下一行:

Hi Member 13209355,

I am assuming your first form name is StaffAccountViewForm, and second form name is RoomBookingForm.

you need to pass the StaffAccountViewForm instance as a parameter to the constructor of the RoomBookingForm. In the constructor you save the form instance to a local variable of the RoomBookingForm. So the following line:
Dim ExitedForm as Form 'Should not be a generic form variable.

更改为:

changes to:

dim ExitedForm As StaffAccountViewForm 'Should be specific to the first form

在此表单的构造函数中:

In the constructor of this form:

Public Sub New(form1 As StaffAccountViewForm)
    InitializeComponent() ' This call is required by the Windows Form Designer.
    ExitedForm = form1
End Sub

来自 StaffAccountViewForm 的电话更改为以下内容:

The call from the StaffAccountViewForm changes to following:

Dim frm2 As RoomBookingForm = New RoomBookingForm(Me) 'Passing the current instance of me
frm2.Show() 'Show the second form
Hide() 'Hide current form

返回按钮代码没关系。也许你想隐藏或关闭第二种形式。希望这会有所帮助。

Back button code is okay. Perhaps you would like to hide or close the second form. Hope this helps.


这篇关于如何返回上一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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