怎么定义函数的返回值

limigy 2006-01-09 11:05:09
例如要写一个函数
sub test(a as int, b as int)
c as int
return c = a + b
end sub
这个程序怎么修改才能有返回值
...全文
266 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2006-01-10
  • 打赏
  • 举报
回复
BYREF:

Sub test(ByVal a As Integer, ByVal b As Integer, Optional ByRef c As Integer)
c = a + b
End Sub

Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer
a = 5
b = 8
test a, b, c
MsgBox c
End Sub
bbhere 2006-01-10
  • 打赏
  • 举报
回复
用Function
Function test(a As Integer, b As Integer) As Integer
Dim c As Integer
c = a + b
test = c
End Function

test即为返回值
begintoday 2006-01-09
  • 打赏
  • 举报
回复
sub test(a as int, b as int)
c as int
return c = a + b
end sub
''''
Function test(a As Integer, b As Integer) As Integer
Dim c As Integer
c = a + b
test = c
End Function

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧