[.NET]請問function的傳回值

看板Visual_Basic作者 (淡)時間19年前 (2005/07/26 14:01), 編輯推噓4(400)
留言4則, 3人參與, 最新討論串1/1
我在module裡宣告一個函數 Public Function ShowPerson(ByRef DataGrid1 As DataGrid) As DataTable Dim connStr, selectCmd As String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PERSONDB.mdb" selectCmd = "Select * From PERSON Order By id_no DESC" Dim conn As OleDbConnection, myAdapter As OleDbDataAdapter Dim myDataSet As New DataSet conn = New OleDbConnection(connStr) conn.Open() myAdapter = New OleDbDataAdapter(selectCmd, conn) myAdapter.Fill(myDataSet, "PERSON") Return myDataSet.Tables("PERSON") End Function 然後我在主程式裡面呼叫 ShowPerson() mydatagrid.DataSource = ShowPerson(mydatagrid) 卻有錯誤 請問這要我要如何呼叫他呢 我是想要傳回一個dataset給在主程式裡的datagrid使用 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.228.174.58

61.222.155.162 07/26, , 1F
你沒給參數
61.222.155.162 07/26, 1F

61.222.155.162 07/26, , 2F
物件要指定 → Set xxx = xxx
61.222.155.162 07/26, 2F

61.228.174.58 07/26, , 3F
問題是出在ShowPerson()這行...
61.228.174.58 07/26, 3F

220.139.173.98 07/26, , 4F
ShowPerson(這裡面要放你的DataGrid參數)
220.139.173.98 07/26, 4F
文章代碼(AID): #12vT7Hy0 (Visual_Basic)
文章代碼(AID): #12vT7Hy0 (Visual_Basic)