我试图编写的程序部分应该接受用户输入,即他们的名字,并在列表框中吐出他们的姓名首字母。到目前为止我已经:
Dim initials As String
Dim indexspace As Integer
initials = name.Substring(0, 1)
indexspace = name.IndexOf(" ")
lstInvoice.Items.Add(String.Format(strFormat, "Invoice ID", initials & space))
当我运行该程序时,我可以弹出第一个首字母,但我不确定如何弹出第二个首字母。
非常感谢您对此事的帮助,非常感谢
最佳答案
Q: How do I find a space (" ") in a string with VB.Net?
A: String.IndexOf("");
Q: How do I find subsequent spaces in the string?
A:提取您找到的第一个空格右侧所有内容的子字符串。
然后对该子字符串执行“.IndexOf(”“)”。
直到你读到字符串的末尾,或者直到你感到无聊:)
关于vb.net - 如何使用子字符串查找空格来显示首字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9041211/