现在问题又来了,我的程序要可以接收两种不同字节数的数据。 于是我在ONCOMM中加了这么一段程序: if x=0 then ;x是判断进来的数应该是几个字节,初始为0 do doevents loop until .inputbuffercount>=3 elseif x=1 then do doevents loop until .inputbuffercount>=9 end if x=0 av=.input ab(0)=av ;又显示下标越界不过以前那个接受9个字节的程序却不显示这样的错误 这究竟是为什么啊?
u can use this to declare the ab arraydim ab( 0 to 10 ) as byteif u use dim ab(10) as byte may be like this dim ab( 1 to 10 ) as byte.
你的AB()怎么定义的啊? dim ab(0 to 9) as byte
你ab(0) av 是如何定义的?
dim a as string*20 for i=1 to 10 ab(i)=cbyte(mid(a,i,2)) next 你可以试一试
于是我在ONCOMM中加了这么一段程序:
if x=0 then ;x是判断进来的数应该是几个字节,初始为0
do
doevents
loop until .inputbuffercount>=3
elseif x=1 then
do
doevents
loop until .inputbuffercount>=9
end if
x=0
av=.input
ab(0)=av ;又显示下标越界不过以前那个接受9个字节的程序却不显示这样的错误
这究竟是为什么啊?
dim ab(0 to 9) as byte
av
是如何定义的?
for i=1 to 10
ab(i)=cbyte(mid(a,i,2))
next
你可以试一试