VB.NET获取一个单词的每个字母并显示在ListBox中

时间:2010-05-12 04:17:40

标签: vb.net

 Private Sub btnWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWord.Click
    Dim Inputter As String
    Dim Words As String = ""

    Do
        Inputter = InputBox("Enter word", "Enter Word")
        If Inputter <> String.Empty Then
            lstDisplay.Items.Add(Inputter)
            Word += Inputter.Substring(0, 1)
        End If
    Loop Until Inputter <> String.Empty
    ' SOMETHING GOES HERE!!!!!'
    lstDisplay.Items.Add("---")
    lstDisplay.Items.Add(Word)
End Sub

以下是它的工作原理,当您单击按钮时,它会显示一个输入框,例如输入“CAT”。

但我无法弄清楚如何让它在列表框中做C(换行符)A(换行符)T(换行符)。请帮忙!

Ç
 一个
 Ť
  -
 CAT

1 个答案:

答案 0 :(得分:1)

Private Sub btnWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWord.Click 
    Dim Inputter As String Dim Words As String = ""

    Inputter = InputBox("Enter word", "Enter Word")
    Dim i as Integer
    For i = 0 To Inputter.Length-1
        lstDisplay.Items.Add( Inputter.Chars(i).ToString )
    Next

    lstDisplay.Items.Add("---")
    lstDisplay.Items.Add(Word)
End Sub