newby VB数组 [英] newby VB arrays

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

问题描述

亲爱的,

如何在初始化后向VB数组添加内容。

dim _points()as System.Drawing.points

如果不可能我怎样才能进入函数,用VB数组作为.NET数组的

参数。



sub func(byval _points()as System.Drawing.points)

....

end sub

sub Main
>
dim _Array as arraylist

_array.add(..)

_array.add(..)

_array.add (..)

func(_array)< ----失败


什么是正确的语法?

谢谢,

Boni

Dear all,
How can I add something to the VB arrays after the initialization.
dim _points() as System.Drawing.points
If it is not possible how can I pass into function, with VB array as an
argument the .NET array.
I.e.
sub func(byval _points() as System.Drawing.points)
....
end sub
sub Main
dim _Array as arraylist
_array.add(..)
_array.add(..)
_array.add(..)
func(_array) <---- fails

What is the correct syntax?
Thanks,
Boni

推荐答案

你没有传递相同的类型参数,即传递的arraylist

到期望数组的函数。尝试以下方法:


sub func(byval _points as Arraylist)


然后在函数中使用_points的元素;


dim b作为点


b = directcast(_points(1),point)


你可以然后直接使用b作为一个点或每次需要使用_points元素时将_points数组元素转换为

a点类型。

-

休斯顿丹尼斯

" Boni"写道:
You are not passing the same type parameter, i.e., an arraylist being passed
to a function expecting an array. Try the following:

sub func(byval _points as Arraylist)

Then in the function when you use an element of _points;

dim b as point

b=directcast(_points(1),point)

You can then use b directly as a point or cast the _points array element to
a point type each time you need to use of _points elements.
--
Dennis in Houston
"Boni" wrote:
亲爱的,
如何在初始化后向VB数组添加内容。
dim _points()as System.Drawing.points 即子函数(byval _points()作为System.Drawing。分)
....
sub sub
sub Main
dim _Array as arraylist
_array.add(..)
_array.add(。 。)
_array.add(..)
func(_array)< ----失败

什么是正确的语法?
谢谢,
Dear all,
How can I add something to the VB arrays after the initialization.
dim _points() as System.Drawing.points
If it is not possible how can I pass into function, with VB array as an
argument the .NET array.
I.e.
sub func(byval _points() as System.Drawing.points)
....
end sub
sub Main
dim _Array as arraylist
_array.add(..)
_array.add(..)
_array.add(..)
func(_array) <---- fails

What is the correct syntax?
Thanks,
Boni



Boni,


\\\

sub func(byval ThisPoints as Arraylist)

dim mypoint as point = DirectCast(ThisPoints(0),System.Drawing.Points)

end sub

sub Main

dim Arl as new arraylist

Arl.Add(.. points)

Arl.add(。 。)

Arl.add(..)

func(Arl)

///

我希望这会有所帮助,


Cor
Boni,

\\\
sub func(byval ThisPoints as Arraylist)
dim mypoint as point = DirectCast(ThisPoints(0), System.Drawing.Points)
end sub
sub Main
dim Arl as new arraylist
Arl.Add(..points)
Arl.add(..)
Arl.add(..)
func(Arl)
///
I hope this helps,

Cor


亲爱的先生们,

我有一个误会。

我没有说,我不能改变功能。它不是我写的(

func的例子是Graphics.FillPolygon(画笔,_points)。

但是我需要动态地创建点数组。是否可能

莫名其妙?

谢谢,

Boni


" Dennis"< De ** **@discussions.microsoft.com> schrieb im Newsbeitrag

news:52 *************************** ******* @ microsof t.com ...
Dear Sirs,
I thing there is a missunderstanding.
I didn'' said, that I can''t change func. It was not written by me (example of
func is Graphics.FillPolygon(brush, _points).
But I need to create the array of points dsynamically. Is it possible
somehow?
Thanks,
Boni

"Dennis" <De****@discussions.microsoft.com> schrieb im Newsbeitrag
news:52**********************************@microsof t.com...
你没有传递相同的类型参数,即一个arraylist被
传递给一个期待的函数尝试以下方法:

sub func(byval _points as Arraylist)

然后在函数中使用_points元素;

dim b as point

b = directcast(_points(1),point)

然后你可以直接使用b作为一个点或者转换_points数组元素

-
休斯顿的丹尼斯

Boni写道:
You are not passing the same type parameter, i.e., an arraylist being
passed
to a function expecting an array. Try the following:

sub func(byval _points as Arraylist)

Then in the function when you use an element of _points;

dim b as point

b=directcast(_points(1),point)

You can then use b directly as a point or cast the _points array element
to
a point type each time you need to use of _points elements.
--
Dennis in Houston
"Boni" wrote:
亲爱的,
如何在初始化后向VB数组添加内容。
dim _points()as System.Drawing.points
如果不可能,我怎样才能进入函数,VB数组作为.NET数组的参数。
即子功能(byval _points()as System.Drawing.points)
....
结束sub
sub Main
dim _Array as arraylist
_array.add(..)
_array.add(..)
_array.add(..)
func(_array)< ----失败

什么是正确的语法?
谢谢,
Boni
Dear all,
How can I add something to the VB arrays after the initialization.
dim _points() as System.Drawing.points
If it is not possible how can I pass into function, with VB array as an
argument the .NET array.
I.e.
sub func(byval _points() as System.Drawing.points)
....
end sub
sub Main
dim _Array as arraylist
_array.add(..)
_array.add(..)
_array.add(..)
func(_array) <---- fails

What is the correct syntax?
Thanks,
Boni



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

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