public function createstringarr() as string()
成都創(chuàng)新互聯(lián)主營溫泉網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app軟件開發(fā)公司,溫泉h5微信小程序搭建,溫泉網(wǎng)站營銷推廣歡迎溫泉等地區(qū)企業(yè)咨詢
return new string(){"d1","d2","d3","d4"}
end function
這兩個函數(shù)都是錯誤的,首先C變量沒有定義,其次作為Function函數(shù)沒有Return返回結(jié)果。
所以兩個函數(shù)運行起來不會返回任何結(jié)果!
像下面這個例子:返回值就是(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、調(diào)用時,這樣子用:
Response.write(b());
3、運行結(jié)果:
abc
Public?Class?Form1
Public?Class?SquareClass?'把多線程調(diào)用的函數(shù)封裝到類中,通過類事件返回
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?'多線程返回值測試,當(dāng)線程運行完成激發(fā)事件
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?'響應(yīng)事件函數(shù)
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過程改成自定義函數(shù),用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
標(biāo)題名稱:vb.net返回,vb 函數(shù)返回
當(dāng)前網(wǎng)址:http://m.rwnh.cn/article8/phjhip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、網(wǎng)站導(dǎo)航、外貿(mào)網(wǎng)站建設(shè)、ChatGPT、動態(tài)網(wǎng)站、
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)