0

I have two TextBoxes..

I want to extract/duplicate ALL CAPITAL LETTERS to be inputted by the user to another TextBox during an event of KeyPress.

Logic :

Private Sub TextBox1_KeyPress()

'If the Character is a Capital Letter Then
'   Copy and Concatenate it to the second TextBox
'End If

End Sub
4

3 に答える 3

2

あなたはこれを試すことができます:

For i = 0 To TextBox1.Text.Length - 1
    Dim c As Char = TextBox1.Text.Chars(i)
    If Char.IsUpper(c) Then
        TextBox2.AppendText(c)
    End If
Next

関数として必要な場合:

Private Function ExtractUppers(ByVal txt As TextBox) As String
    Dim sExtract As String = ""
    For i = 0 To txt.Text.Length - 1
        Dim c As Char = txt.Text.Chars(i)

        If Char.IsUpper(c) Then
            sExtract = sExtract & c
        End If
    Next

    Return sExtract
End Function

そしてあなたのボタンで:

 TextBox2.Text = ExtractUppers(TextBox1)
于 2013-01-10T16:44:00.247 に答える
2

友達に解決してもらいました!:) お返事ありがとうございます!

Private Sub TextBox1_TextChange()

      CapitalLetter = Regex.Replace(TextBox1.Text, "[^A-Z]", String.Empty)
      TextBox2.Text = CapitalLetter

End Sub
于 2013-01-10T17:09:10.617 に答える
0

多分あなたはこのトリックを使うことができます:

If letterVar = letterVar.ToUpper() then
    TextBox2.Text &= letterVar
End if
于 2013-01-10T16:53:52.810 に答える