在VB.NET表单之间传递数据

编程入门 行业动态 更新时间:2024-10-23 01:32:10
本文介绍了在VB.NET表单之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个表单有一个按钮,点击它会弹出一个对话窗体。在此对话框内,用户需要选择一些数据,用户完成后,点击OK按钮。一旦他们单击确定按钮,它需要返回一个整数返回到上一个表单。

我创建了一个对话框,并尝试通过以下代码调用:

Dim intResult as Integer = frmData.ShowDialog() Debug.Writeline(intResult)

但是,似乎我只能返回DialogResults(中止,取消,忽略...)

我想知道如何无需创建一个公共变量并存储结果就可以尝试,

解决方案>

在对话框中创建一个返回值的属性。

如果frmData.ShowDialog()不是DialogResult。取消 Dim值as integer = frmData.MyProperty ... Endif

I have a form that has a button, when clicked it pops up a Dialog Form. Within this dialog form the user needs to select some data and when the user is finished they click the OK button. Once they click the OK button it needs to return an integer back to the previous form.

I created a Dialog Form and tried calling it via the code below:

Dim intResult as Integer = frmData.ShowDialog() Debug.Writeline(intResult)

However, it seems I can only return DialogResults (Abort, Cancel, Ignore...)

I was wondering how I can try this without having to create a public variable and storing the result there.

解决方案

Create a property on the Dialog that will return the value.

If frmData.ShowDialog() Is Not DialogResult.Cancel Dim value as integer = frmData.MyProperty ... Endif

更多推荐

在VB.NET表单之间传递数据

本文发布于:2023-11-03 20:27:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1556007.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   数据   VB   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!