我在数据库中有一个文本是“计算机硬件”。我用那段代码分割
' 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
但现在我希望在textbox1中获得“computer”,在textbox2中获得“hardware”。
请指导我
答案 0 :(得分:5)
如果我理解正确,请使用以下代码行替换For
循环:
textbox1.Text = arInfo(0)
textbox2.Text = arInfo(1)
顺便说一下,初始化arInfo
(... = New String(3) {}
)不是必需的,因为您无论如何都会覆盖arInfo
的值(arInfo = ...
)。