关于函数调用的问题。
偶定义了一个函数如下
private function insertdata(tablename as string, fieldid as string)
函数体
end function
当我调用的时候insertdata("hello", "world")总是提示出错,错误信息如下
complile error:
expected:=
我要是函数只定义一个参数就没错,这是什么原因????
推荐阅读
call insertdata("hello", "world")
or
insertdata "hello", "world"
call 函数名(参数)
函数名 参数
用 function 关键字来定义函数,需要数据返回的
而用 sub 则不能返回数据
同时注意,在定义函数的时候参数变量是用byref,还是byval格式,两者没有弄清楚也会出现错误的。
先添加三个文本框.一个按钮
加入下列带码:
dim c as string
public function wwa(fd as string, d as string)
c = fd + d
wwa = c
end function
private sub command1_click()
text3.text = wwa(text1.text, text2.text)
end sub
你的函数定义缺少返回值,改为:
private function insertdata(tablename as string, fieldid as string) as 返回值
函数体
end function
如果确实没有返回值,应该定义成过程,如下:
private sub insertdata(tablename as string, fieldid as string)
函数体
end sub


讨论区