【加试题】小马正在看一本侦探小说,想了解其中一段案情的解析,却发现了一串字符“#2017—2018go:)”,并附有文字提示:①答案所在的页码是这串字符中最大数字字串(若值相同则取后面的数字字串)的起始位置*10+结束位置②答案所在行号是最大数值除以100的余数。例如:“#17a18#”字符串中,最大数字字串“18”。起始位置是5,结束位置是6,其页码是56,行号是18。小马编写了一个VB程序帮他寻找答案,程序运行界面如图所示。在文Text2中输出页码,在Text3中输入行号。实现上述功能的VB程序代码如下,但加框处代码有错,请改正。Private Sub Command1_Click() Dim s1 As String,s2 As String Dim ch As String,ch2 As String Dim max As Double Dim n As Integer,page As Integer Dim i As Integer,j As Integer s1=Text1.Text:s2=”” n=Len(s1) i=1:max=0 Do While i<=n ch=Mid(s1,i,1) If ch>=“0”And ch<=“9”Then j=i ch2=Mid(s1,i,1) Do While ch2>=“0”And ch2<=“9” j=j+1 ch2=Mid(s1,j, 1) Loop s2= ’(1) If Then ’(2) max=Val(s2) page=i*10+j-1 Text2.Text=Str(page) Text3.Text=Str(max Mod l00) End If i=j End If i=i+1 Loop End Sub
(1)
处加框代码应改为;
(2)
处加框代码应改为。
答案: 【1】Mid(s1,i,j-i)
【1】Val(s2)>=max