Private Sub test()
Dim a As String
a = InputBox("请输入数字.")
Dim s As Integer = 0
For i As Integer = 0 To a.Length - 1
s += CInt(a.Substring(i, 1))
Next
MessageBox.Show(s.ToString)
End Sub
'vb.net 语句
在label1上显示数据,则:
dim i,j,x
j=0
x=InputBox("请输入数字.")
for i=1 to len(cstr(x))
j=cint(mid(cstr(x),i,1))+j
next
label1.caption=cstr(j)