幼儿中班语言故事教案:VB中关于自定义函数问题
来源:百度文库 编辑:高校问答 时间:2024/05/01 07:29:02
请问VB中如何自定义函数?格式是怎样的?请举个例子说明
'定义函数,返回值是Max
Function Max(a as Integer,b as Integer) as Integer
If a>b then
Max=a
Else
Max=b
End if
End Function
'使用该函数
MsgBox Max(1234,433) 将弹出一个消息框,显示的值为1234
'有返回值的函数
'作用把字符串里面的'转化为''
function getValue(str1 As String)
getValue= Replace(str1, "'", "''")
end function
用法:
string1=getValue(string1)
无返回值函数
sub sub1()
......
end sub