[问答题] 改错题(14分) 【题目】 本程序的功能是:找出100~999之间的十进制数为升序数,且其对应的八进制数也是升序数的整数。所谓升序数,是指该数的十位数字值大于个位数字值,百位数字值大于

16 查阅

[问答题] 改错题(14分) 【题目】 本程序的功能是:找出100~999之间的十进制数为升序数,且其对应的八进制数也是升序数的整数。所谓升序数,是指该数的十位数字值大于个位数字值,百位数字值大于十位数字值。 Option Explicit Private Sub CmdFind_Click()Dim n As Integer,s8 As StringFor n=100 To 999 s8=d2Q(n) If sx(n) And sx(Val(s8)) Then List1.AddItem n & "D==>" & s8 & "Q" End IfNext n End Sub Private Function d2Q(n As Integer) As StringDim p As IntegerDo p=n Mod 8 d2Q=d2Q & CStr(P) n=n8Loop Until n=0 End Function Private Function sx(ByVal n As Integer)As BooleanDim num() As Integer,k As Integer,t As IntegerDim i As Integert=Len(CStr(n))ReDim num(t)For k=1 To t num(k)=Val(Mid(CStr(n),k,1))next kFor i=1 To UBound(num)-1 If num(i)>=num(i+1) Then Exit ForNext isx=True End Function【要求】1.新建工程,输入上述代码,改正程序中的错误。2.改错时,不得增加或删除语句,但可适当调整语句的位置。3.将窗体文件和工程文件分别命名为F1和P1,并保存到T盘根目录下。

参考答案:

Private Function d2Q(n As Integer) As String 改为ByVal n As Integer d2Q=a2Q & cstr(p) 改为cstr(p) & d2Q If num(i)>=num(i+1) Then Exit For 改为Exit Function

计算机考试