十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
public function createstringarr() as string()
成都创新互联主营温泉网站建设的网络公司,主营网站建设方案,app软件开发公司,温泉h5微信小程序搭建,温泉网站营销推广欢迎温泉等地区企业咨询
return new string(){"d1","d2","d3","d4"}
end function
这两个函数都是错误的,首先C变量没有定义,其次作为Function函数没有Return返回结果。
所以两个函数运行起来不会返回任何结果!
像下面这个例子:返回值就是(obj Is Nothing),在VB.Net中最好使用Return (obj Is Nothing),而不是IsNothing=(obj Is Nothing)。
Public Function IsNothing(obj As Object) As Boolean
Return (obj Is Nothing)
End Function
1、我有一个function,如下:
function b()
'...
return "abc"
end function
2、调用时,这样子用:
Response.write(b());
3、运行结果:
abc
Public Class Form1
Public Class SquareClass '把多线程调用的函数封装到类中,通过类事件返回
Public Value As Double
Public Square As Double
Public Event ThreadComplete(ByVal Square As Double)
Public Sub CalcSquare()
Square = Value * Value
RaiseEvent ThreadComplete(Square)
End Sub
End Class
Dim WithEvents oSquare As SquareClass
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '多线程返回值测试,当线程运行完成激发事件
oSquare = New SquareClass()
Dim t As New Threading.Thread(AddressOf oSquare.CalcSquare)
oSquare.Value = 30
t.Start()
End Sub
Sub SquareEventHandler(ByVal Square As Double) Handles oSquare.ThreadComplete '响应事件函数
MsgBox("The square is " Square)
End Sub
End Class
'form1 窗体上添加一个button1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Button1.DialogResult = Windows.Forms.DialogResult.OK
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close()
End Sub
'以上是form1的代码
'然后就可以
dim a as new form1
dim b as dialogresult
b=a.showdialog()
你的 sub过程这个是子过程,无返回值的,这里Form1_Load中b仍然 b=""
如果你想b="注释",将你的sub过程改成自定义函数,用b来接收返回值就行了,代码如下
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim a As String = "rem"
Dim b As String = ""
b = sub过程(b, a)
Me.Text = b '为什么“b”不是等于 "注释"
End Sub
Private Function sub过程(ByVal 输出 As String, ByRef 输入 As String) As String
If 输入 = "rem" Then
输出 = "注释"
End If
Return 输出
End Function