如何在VB.NET中以多种形式执行相同的操作 [英] How can I do same action in multiple form in VB.NET

查看:79
本文介绍了如何在VB.NET中以多种形式执行相同的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i在vb.net中有3个表格

并且所有这些表格都包含相同的文本框来强制显示文本文件并读取它在里面

但问题是我必须在每个表单中导入文本文件



我怎样才能导入文本文件一次

它将填写所有形式的所有文本框



我尝试过:



TextBox3.Text = System.IO.File.ReadAllText(C:\ test.txt)

解决方案

< blockquote>创建一个类来保存该数据。读取一次并将类的引用传递给表单


创建此表单操作的类表单。并以您想要的任何形式应用该课程......


Hi everyone,

i have 3 forms in vb.net
and all of them contain same textbox to imprt text file and read it in it
but the problem i have to import the text file in each form

how can i import the text file only one time
and it will fill it in all textboxes in all forms

What I have tried:

TextBox3.Text = System.IO.File.ReadAllText("C:\test.txt")

解决方案

Create a class to hold that data. Read it once and pass a reference to the class to the form


create the class form this form actions. And apply the class in any forms you wanted...


这篇关于如何在VB.NET中以多种形式执行相同的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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