2014-02-14 55 views
0

我試圖在文本框中顯示兩個不同表格中的兩個值與一個特定機構的關係。將兩個不同列中的兩個值顯示爲一個文本框

我寫的代碼沒有顯示「advisor_name」,只顯示「Influence_weight_name」。我也希望這兩個名稱都顯示在一行上,所以最終產品應該看起來像這樣:顧問名稱 - 重量名稱

任何人都可以幫忙嗎?

下面是我的代碼:

Dim totalRecords As Integer = sqlTableInstitution.Rows.Count 
      Dim advisorText As String = "" 
      Dim weightText As String = "" 

      If IsDBNull(sqlTableInstitution.Rows(0)("advisor_name")) <> True Then 
       advisorText = sqlTableInstitution.Rows(0)("advisor_name") 
      End If 

      If IsDBNull(sqlTableInstitution.Rows(0)("Influence_weight_name")) <> True Then 
      weightText = weightText & "-" & sqlTableInstitution.Rows(0)("Influence_weight_name") 
      End If 
Textbox1.text = advisorText 
Textbox1.text = weightText 

回答

1
Private Function GetData() As String 
    Dim totalRecords As Integer = sqlTableInstitution.Rows.Count 
    Dim advisorText As String = "" 
    Dim weightText As String = "" 
    Dim result As String 
    If Not IsDBNull(sqlTableInstitution.Rows(0)("advisor_name")) Then 
    advisorText = sqlTableInstitution.Rows(0)("advisor_name") 
    If Not IsDBNull(sqlTableInstitution.Rows(0)("Influence_weight_name")) Then 
     weightText = sqlTableInstitution.Rows(0)("Influence_weight_name") 
     result = String.Format("{0}-{1}",advisorText, weightText) 
    End If 
    End If 
    Return result 
End Function 
1

這是因爲當你到達這條線

Textbox1.text = weightText 

weightTextweightText

嘗試更換Textbox1.Text而不將它的替換後續荷蘭國際集團代碼

Textbox1.text = advisorText 
Textbox1.text = weightText 

與此代碼

Textbox1.Text = advisorText & weightText 
相關問題