如何在visual basic中获取字符串中所有数字的总和? – -例如 – – Dim userWord As StringuserWord = Console.ReadLine() 用户输入:“福克斯跳过12月” 输出显示:3 杰里恩说: Dim mytext As String = "12
– -例如 – –
Dim userWord As String userWord = Console.ReadLine()
用户输入:“福克斯跳过12月”
输出显示:3
杰里恩说:Dim mytext As String = "123a123" Dim sum As Integer = 0 For Each ch As Char In mytext Dim i As Integer If Integer.TryParse(ch, i) Then sum += i End If Next