我想在vb.net的文本框中读取用户给出的值。 如果他们给出值ABC,我想逐个读取字符串并在另一个文本框中显示特定字符(例如第3个字符(c))。
答案 0 :(得分:3)
假设您有2个文本框和一个按钮:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim textBox1InputString As String
textBox1InputString = TextBox1.Text
' Call ToCharArray function.
Dim array() As Char = textBox1InputString.ToCharArray
' If we input ABC and we want C
TextBox2.Text = array(2)
End Sub
答案 1 :(得分:1)
For i = 0 To TextBox1.Text.Length
If i = 2 Then
TextBox2.Text = TextBox1.Text(i)
End If
Next