- 最後登錄
- 2024-5-1
- 在線時間
- 296 小時
- 註冊時間
- 2009-2-23
- 閱讀權限
- 20
- 精華
- 0
- UID
- 5903028
- 帖子
- 39
- 積分
- 0 點
- 潛水值
- 9511 米
| 若有安裝色情守門員,可用無界、自由門等軟件瀏覽伊莉。或使用以下網址瀏覽伊莉: http://www.eyny.com:81/index.php 本帖最後由 darkjack 於 2014-7-5 05:36 PM 編輯
- 不好意思我又來打擾了~~XD~請教各位先進 在Property 的問題 ~我想問的是~在不同的表單中傳遞字串~是不是不能直接 New Property 的類別來使用呢?還是我的寫法錯了~我有看過MSDN,Property的用法只是大概瞭解~使用的邏輯還是要加強~可否請個位先進說明一下~謝謝
複製代碼- Public Class Form1
-
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
- MaintainRecordDataSet.EnforceConstraints = False
- 'TODO: 這行程式碼會將資料載入 'MaintainRecordDataSet.MaintainDetails' 資料表。您可以視需要進行移動或移除。
- Me.MaintainDetailsTableAdapter.Fill(Me.MaintainRecordDataSet.MaintainDetails)
- 'TODO: 這行程式碼會將資料載入 'MaintainRecordDataSet.Maintain' 資料表。您可以視需要進行移動或移除。
- Me.MaintainTableAdapter.Fill(Me.MaintainRecordDataSet.Maintain)
- MaintainRecordDataSet.EnforceConstraints = True
- End Sub
複製代碼- Public Class Form2
- Private Sub Form2_Load(sender As Object, e As EventArgs) Handles Me.Load
- Dim STR As New TGetString
- STR.GetName = TextBox1.Text <==為什麼Textbox1的值是空的
- End Sub
- End Class
複製代碼- Public Class TGetString
- Dim FGetName As String
- Property GetName As String
- Get
- Dim cnStr As String = My.Settings.MoodAccountConnectionString
- Dim cnConnection As New SqlConnection(cnStr)
- Dim cmStr As String = "SELECT ReplaceParts FROM MaintainDetails WHERE ReplaceParts = '" & CStr(MaintainRecord.MaintainDetailsDataGridView.CurrentRow.Cells(1).Value) & "'"
- Dim cmCommand As New SqlCommand(cmStr, cnConnection)
- cnConnection.Open()
- Dim dr As SqlDataReader = cmCommand.ExecuteReader
- If dr.Read Then
- FGetName = dr.GetString(0)
- End If
- cnConnection.Close()
- GetName = FGetName
- End Get
- Set(value As String)
- FGetName = value
- End Set
- End Property
- End Class
複製代碼
不好意思類別貼不上~~~請見諒!
... |
|