如何声明可以通过表单编辑的公共变量?VB.Net [英] How declare a public variable that can be edit by forms?VB.Net

查看:74
本文介绍了如何声明可以通过表单编辑的公共变量?VB.Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为主题,如果我要创建一个数组,其中数组的内容可以通过form1和form2来编辑数组,我将如何进行
呢?

例如数组的内容是{1,2,3}


form2将内容更改为{1,2,4}


form1也可以看到数组中的变化

我应该声明数组和wat是格式吗?

我怎么样在form1和form2中调用数组

进行修改?

任何帮助都非常感谢... ... ...

as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?
any help is greatly appreciated...thz...

推荐答案

嗨MJ,


如果它是一个固定数组,你可以做一个共享类这样的


公共类mySample

私有共享myRealArray为Integer()= {1,2,3}

公共共享属性MyArray()为整数()

获取

返回myRealArray

结束获取

设置(ByVal值为整数())

myRealArray =价值

结束集

结束财产

结束班级


现在你可以使用

mySample.myArray( 2)= 4


但是也看看arraylist,因为这不是一个很好的例子,

我确实试着回答你的问题你在问。如果你想要
redim你的数组,你必须为你的类添加一个方法。 (公共分享Sub

或功能)


我希望这会有所帮助,


Cor

Hi MJ,

If it is a fixed array you can do making a shared class as this

Public Class mySample
Private Shared myRealArray As Integer() = {1, 2, 3}
Public Shared Property MyArray() As Integer()
Get
Return myRealArray
End Get
Set(ByVal Value As Integer())
myRealArray = Value
End Set
End Property
End Class

Now you can use everywhere that array by
mySample.myArray(2) = 4

But have a look at arraylist also, because this is not such a nice example,
I did try to answer your question exactly as you was asking. If you want to
redim your array, you have to add a method to your class. (public shared Sub
or function)

I hope this helps,

Cor

作为主题,如果我要创建一个数组,其中数组的内容可以由form1和form2编辑,我将如何去做?
例如数组的内容是{1,2,3}
form2将内容更改为{1,2,4}

form1也可以看到数组中的变化
我应该声明数组和wat是格式吗?
我将如何调用form1和form2中的数组进行修改?
as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?






除了Cor的评论,你需要在一个公共阵列中建立一个

模块通过项目提供。


Public myArray()As Integer = {1,2,3}

Ken

--------------------

" MJ" < MJ ***** @ pd.jaring.my>在消息中写道

news:13 ***************************** @ phx.gbl ...
Hi,

In addition to Cor''s comments you need to make a public array in a
module to make available through the project.

Public myArray() As Integer = {1, 2, 3}
Ken
--------------------
"MJ" <mj*****@pd.jaring.my> wrote in message
news:13*****************************@phx.gbl...
作为主题,如果我要创建一个数组,其中数组的内容可以由form1和form2编辑,我将如何去做?例如数组的内容是{1,2,3}

form2将内容更改为{1,2,4}

form1也可以看到数组
我应该声明数组和wat是格式吗?
我将如何在form1和form2中调用数组进行修改?
任何帮助都很大赞赏... ... ...
as topic, if i wan to create an array where the content of
the array can be edited by form1 and form2, how i going to
do it?
for example the content of array is {1,2,3}

form2 change the content to {1,2,4}

form1 also can see the changes in the array
where i should declare the array and wat is the format?
and how am i going to call the array in form1 and form2
for modification?
any help is greatly appreciated...thz...



嗨Ken,
Hi Ken,
除了Cor的评论你需要在一个
模块中创建一个公共数组,以便通过该项目提供。
In addition to Cor''s comments you need to make a public array in a
module to make available through the project.



很抱歉尝试更正你,但我想你确实想说


除了Cor的评论,您还可以在
中制作公共阵列
模块通过项目提供。


如果我不发布这个OP可能会理解它错了并且两者都有。


:-)

Cor


Sorry for trying correctiong you, but I think you did want to say

In addition to Cor''s comments you can also make a public array in a
module to make available through the project.

If I dont post this the OP does maybe understand it wrong and does both.

:-)

Cor


这篇关于如何声明可以通过表单编辑的公共变量?VB.Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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