代码一:
Dim x(100),y(100) As Byte
Call ReadBytes(x) Public Sub ReadBytes(ByRef z() As Byte) 'Do Nothing End Sub
对以上代码进行编译,你会发现编译并不能通过。 代码二:
Dim x(100) As Byte,y(100) As Byte
Call ReadBytes(x) Public Sub ReadBytes(ByRef z() As Byte) 'Do Nothing End Sub
调试以上代码,通过。 从C语言或其他语言转过来的程序员,很容易犯代码一的错误,因为在VB中:
Dim x(100),y(100) As Byte
等效于:
Dim x(100)
Dim y(100) As Byte
Dim x(100) As Byte
Dim y(100) As Byte
这个错误非常隐蔽,而且并不常见在编程新手身上,而是有过很长时间其他语言编程经验的老程序员身上,希望这篇文章能够使你避免犯这样的错误。 |
|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )
GMT+8, 2024-5-14 23:24 , Processed in 0.076699 second(s), 16 queries .
Powered by Discuz! X3.3
© 2001-2017 Comsenz Inc.