VB改错,急! 本程序的功能是找出1300~1500内符合以下条件的四位正整数:设四位正整数各位数
答案:2 悬赏:0 手机版
解决时间 2021-11-14 00:18
- 提问者网友:树红树绿
- 2021-11-13 00:18
VB改错,急! 本程序的功能是找出1300~1500内符合以下条件的四位正整数:设四位正整数各位数
最佳答案
- 五星知识达人网友:十年萤火照君眠
- 2021-11-13 00:28
追答VB改错,急!
本程序的功能是找出1300~1500内符合以下条件的四位正整数:设四位正整数各位数字分别为a、b、c、d,要求a+b=c+d。
Option Explicit
Private Sub Command1_Click()
Dim ts(2) As Integer
Dim i As Integer, j As Integer, f As Boolean, st As String
For i = 1300 To 1500
Call sub1(i, f, ts)
f = False
If f Then
st = i & " "
For j = 1 To 2
st = st & ts(j) & " "
Next j
List1.AddItem st
End If
st = ""
Next i
End Sub
Private Sub sub1(n As Integer, f As Boolean, ts() As Integer)
ts(1) = n \ 100: ts(2) = n Mod 100
If sum(ts(1)) = sum(ts(2)) Then f = True
End Sub
Private Function sum(a As Integer)
Dim k As Integer
Do
k = a Mod 10
sum = sum + k
a = a / 10
Loop Until a = 0
End Function
全部回答
- 1楼网友:深街酒徒
- 2021-11-13 01:25
a=Val(Text1.Text)s=0Fori=1To4s=s+aMod10a=a\10NextiText2.Text=Str(s)EndSubPrivateSubCommand2_Click()Text1.Text=""Text2.Text=""EndSub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯