后期绑定 [英] Late Binding

查看:74
本文介绍了后期绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我决定在我的一个应用程序中使用Options Strict ON,现在我正在尝试

来修复迟到的约束问题。我有5个整数数组:


dim IA1(500),IA2(500),IA3(500),IA4(500),IA5(500)为整数


这些数组中的整数实际上是指向文本文件中不同列的

数据的指针。


我创建一个数组这些数组:


Dim HIndex()as Array = {IA1,IA2,IA3,IA4,IA5}


然后我用两个循环从数组的aray中检索整数:


Dim xHeader()as String

Dim T_xHeader as ArrayList


对于s = 0到4

做一些东西

对于i = 0到HIndex(s).Length -1

做一些东西

T_xHeader.Add(xHeader(HIndex(s)(i)))''后期绑定在这里

下一个我

做一些东西

下一页


因此,HIndex(s)(i)实际指向xHeader中的值,然后添加

到T_xHeader。


这一切都运行正常,但是,因为我正在将HIndex标注为数组,我' '

得到一个后期绑定错误。


我无法弄清楚如何将HIndex维度化为除数组之外的其他内容,

以避免后期绑定。


任何想法都将不胜感激!!


TIA

Lee

解决方案

Lee,


你能看看这个旧的,但简单的样本来自我在这个

消息

http://groups-beta.google.com/group/...e0848bf3?hl=en


如果这还不够,请随时回复


我希望这会有所帮助,


Cor


大家好,


我正在玩关于我的第一篇文章的一些想法。


我要做的第一件事是摆脱阵列数组(因为它是符合CLS标准的
。所以,我正在添加一个字符串数组,其中包含

整数数组的名称:

Dim IA1(500),IA2(500),IA3 (500),IA4(500),IA5(500)为整数


Dim xHeader()as String

Dim T_xHeader as ArrayList


For s = 0到Sname.Length - 1

做一些东西

对于i = 0到CType(Sname(s).Clone,Array).Length - 1
做一些事情

T_xHeader.Add(xHeader(Sname(s).Clone(i)))''后期绑定在这里

下一页i
接下来s


所以,我设法摆脱阵列阵列,但我仍然有

后期绑定问题。


我要避免的是:


For s = 0到Sname.Length - 1

做一些东西

如果Sname(s)=" IA1"然后

对于i = 0到IA1.Length - 1

做一些事情

T_xHeader.Add(xHeader(IA1(i))) ''早期绑定

下一页i

Elseif Sname(s)=" IA2"然后

对于i = 0到IA2.Length - 1

做一些事情

T_xHeader.Add(xHeader(IA2(i))) ''早期绑定

下一页i

Elseif Sname(s)=" IA3"然后

对于i = 0到IA3.Length - 1

做一些事情

T_xHeader.Add(xHeader(IA3(i))) ''早期绑定

下一页i

Elseif Sname(s)=" IA4"然后

对于i = 0到IA4.Length - 1

做一些事情

T_xHeader.Add(xHeader(IA4(i))) ''早期绑定

下一页i

Elseif Sname(s)=" IA5"然后

对于i = 0到IA5.Length - 1

做一些事情

T_xHeader.Add(xHeader(IA5(i))) ''早期绑定

下一页我

Endif

做一些事情

下一页


原因我试图避免这是为了防止大量必要的代码

如果整数数组的数量发生变化则会发生变化。使用我的第一个(后期

绑定)方法,唯一的变化是维度另一个Integer

数组并将其名称添加到字符串数组中。


TIA

Lee

" lgbjr" < LG *** @ online.nospam>在消息中写道

新闻:OJ ************** @ TK2MSFTNGP10.phx.gbl ...

hi全部,

我决定在我的一个应用程序中使用Options Strict ON,现在我正在尝试修复后期绑定问题。我有5个整数数组:

dim IA1(500),IA2(500),IA3(500),IA4(500),IA5(500)为整数

这些数组中的整数实际上是指向文本文件中不同列数据的指针。

我创建了这些数组的数组:

Dim HIndex()as Array = {IA1,IA2,IA3,IA4,IA5}
然后我使用两个循环从数组的aray中检索整数:

Dim xHeader()as String
Dim T_xHeader as ArrayList

对于s = 0到4
做一些事情
对于i = 0到HIndex(s).Length -1
做一些东西
T_xHeader.Add(xHeader(HIndex(s)(i)))''后期绑定在这里
接下来我
做一些事情
下一个s

所以,HIndex(s)(i)实际上指向xHeader中的一个值,然后将其添加到T_xHeader。

这一切都很好,但是,因为我'我将HIndex标注为一个数组,我是一个迟到的绑定错误。

我无法弄清楚将HIndex维度化为数组以外的其他东西,
以避免后期绑定。

任何想法都将不胜感激!!

TIA Lee



Lee,


查看我之前的消息,知道IList几乎是每个人的接口

除了VB集合之外的标准数组和集合实现。


因此可以使用。


Cor

hi All,

I''ve decided to use Options Strict ON in one of my apps and now I''m trying
to fix a late binding issue. I have 5 integer arrays:

dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer

The integers in these arrays are actually pointers to different columns of
data in a text file.

I create an array of these arrays:

Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}

Then I use two loops to retrieve the integers from the aray of arrays:

Dim xHeader() as String
Dim T_xHeader as ArrayList

For s = 0 to 4
Do some stuff
For i = 0 to HIndex(s).Length -1
Do some stuff
T_xHeader.Add(xHeader(HIndex(s)(i))) ''Late Binding Here
Next i
Do some stuff
Next s

So, HIndex(s)(i) actually points to an value in xHeader, which is then added
to T_xHeader.

This all works fine, but, becasue I''m dimensioning HIndex as an array, I''m
getting a late binding error.

I can''t figure out how to dimension HIndex to something other than array, in
order to avoid the late binding.

Any ideas would be greatly appreciated!!

TIA
Lee

解决方案

Lee,

Can you have a look at this older however simple sample from me in this
message

http://groups-beta.google.com/group/...e0848bf3?hl=en

When this is not enough, feel free to reply

I hope this helps,

Cor


Hi All,

I''m playing with some ideas regarding my first post.

The first thing I''m trying to do is get rid of the Array of Arrays (as it''s
not CLS compliant). So, I''m adding a string array with the names of the
integer arrays:

Dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer
Dim Sname as String() = {"IA1", "IA2", "IA3", "IA4", "IA5"}

Dim xHeader() as String
Dim T_xHeader as ArrayList

For s = 0 to Sname.Length - 1
Do some stuff
For i = 0 to CType(Sname(s).Clone, Array).Length - 1
Do some stuff
T_xHeader.Add(xHeader(Sname(s).Clone(i))) ''Late Binding Here
Next i
Do some stuff
Next s

So, I''ve managed to get rid of the array of arrays, but I still have the
late binding issue.

What I''m tring to avoid is this:

For s = 0 to Sname.Length - 1
Do some stuff
if Sname(s) = "IA1" Then
For i = 0 to IA1.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA1(i))) ''Early Binding
Next i
Elseif Sname(s) = "IA2" then
For i = 0 to IA2.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA2(i))) ''Early Binding
Next i
Elseif Sname(s) = "IA3" then
For i = 0 to IA3.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA3(i))) ''Early Binding
Next i
Elseif Sname(s) = "IA4" then
For i = 0 to IA4.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA4(i))) ''Early Binding
Next i
Elseif Sname(s) = "IA5" then
For i = 0 to IA5.Length - 1
Do some stuff
T_xHeader.Add(xHeader(IA5(i))) ''Early Binding
Next i
Endif
Do some stuff
Next s

the reason I''m trying to avoid this is to prevent lots of necessary code
changes if the number of Integer arrays changes. Using my first (late
binding) method, the only changes would be to dimension another Integer
array and add it''s name to the string array.

TIA
Lee
"lgbjr" <lg***@online.nospam> wrote in message
news:OJ**************@TK2MSFTNGP10.phx.gbl...

hi All,

I''ve decided to use Options Strict ON in one of my apps and now I''m trying
to fix a late binding issue. I have 5 integer arrays:

dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer

The integers in these arrays are actually pointers to different columns of
data in a text file.

I create an array of these arrays:

Dim HIndex() as Array = {IA1, IA2, IA3, IA4, IA5}

Then I use two loops to retrieve the integers from the aray of arrays:

Dim xHeader() as String
Dim T_xHeader as ArrayList

For s = 0 to 4
Do some stuff
For i = 0 to HIndex(s).Length -1
Do some stuff
T_xHeader.Add(xHeader(HIndex(s)(i))) ''Late Binding Here
Next i
Do some stuff
Next s

So, HIndex(s)(i) actually points to an value in xHeader, which is then
added to T_xHeader.

This all works fine, but, becasue I''m dimensioning HIndex as an array, I''m
getting a late binding error.

I can''t figure out how to dimension HIndex to something other than array,
in order to avoid the late binding.

Any ideas would be greatly appreciated!!

TIA
Lee



Lee,

See my earlier message, know that IList is the interface that almost every
standard array and collection implements except the VB collection.

And therefore can be used.

Cor


这篇关于后期绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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