2010-01-09 64 views
1

我在數據庫中有一個文本是「計算機硬件」。我使用的代碼,以分割string.split vb.net

  ' string seperated by colons '-' 
      Dim info As String = strcotegory 

      Dim arInfo As String() = New String(3) {} 

      ' define which character is seperating fields 
      Dim splitter As Char() = {"-"c} 

      arInfo = info.Split(splitter) 

      For x As Integer = 0 To arInfo.Length - 1 
       Response.Write(arInfo(x) & "</br> ") 
      Next 

但現在我想在TextBox2中TextBox1中和「硬件」得到「電腦」。

請指導我

回答

5

如果我理解正確的話,用下面的代碼行替換For循環:

textbox1.Text = arInfo(0) 
textbox2.Text = arInfo(1) 

順便說一句,初始化arInfo... = New String(3) {})是沒有必要的,因爲無論如何你都會覆蓋arInfo的值(arInfo = ...)。