VB中,如何对文本框中的每行固定字符进行运算处理?

2024-11-01 12:30:58
推荐回答(1个)
回答1:

Private Sub Command1_Click() Dim a As Variant Dim s1 As Integer, s2 As Integer Dim str As Variant a = Split(Text1.Text, vbCrLf) s1 = 0 s2 = 0 For Each str In a s1 = s1 + Val(Mid(Trim(str), 1, 1)) s2 = s2 + Val(Mid(Trim(str), 5, 1)) Next MsgBox s1 & " " & s2 End Sub