用vb中求一个4位数各位数字之和的代码
答案:2 悬赏:50 手机版
解决时间 2021-02-19 05:03
- 提问者网友:低吟詩仙的傷
- 2021-02-18 18:57
用vb中求一个4位数各位数字之和的代码
最佳答案
- 五星知识达人网友:思契十里
- 2021-02-18 19:59
Private Sub Command1_Click()
Dim a(4) As Integer
x = Text1.Text
For i = 1 To 4
a(i) = Mid(x, i, 1)
Next
For i = 1 To 4
Print a(i);
Next
End Sub
Dim a(4) As Integer
x = Text1.Text
For i = 1 To 4
a(i) = Mid(x, i, 1)
Next
For i = 1 To 4
Print a(i);
Next
End Sub
全部回答
- 1楼网友:末日狂欢
- 2021-02-18 21:15
Private Sub Command1_Click()
Dim a, b, c, d, e
a = 1234
b = Int(a 1000)
c = Int((a - b * 1000) 100)
d = Int((a - b * 1000 - c * 100) 10)
e = a Mod 10
Print b + c + d + e
End SubPrivate Sub Command1_Click()
Dim a, b, c, d, e
a = 1234
b = Int(a 1000)
c = (a Mod 1000) 100
d = (a Mod 100) 10
e = a Mod 10
Print b + c + d + e
End Sub
Dim a, b, c, d, e
a = 1234
b = Int(a 1000)
c = Int((a - b * 1000) 100)
d = Int((a - b * 1000 - c * 100) 10)
e = a Mod 10
Print b + c + d + e
End SubPrivate Sub Command1_Click()
Dim a, b, c, d, e
a = 1234
b = Int(a 1000)
c = (a Mod 1000) 100
d = (a Mod 100) 10
e = a Mod 10
Print b + c + d + e
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯