实现上述功能的VB程序如下,但加框处代码有错,请改正。
Dim n As Integer, cy(30000) As String
Private Sub Form_Load()
'从数据库中读入n条成语,并存数组cy中
'代码略
End Sub
Private Sub Command1_Click()
Dim s As String, i As Integer, j As Integer
Dim m As Integer, flag As, Boolean
Dim s1 As Siring, s2 As String
s=Text1.Text
flag=True
Do While flag
'①
i=1
j=n
Do While<= j
m= Int((i+j)/2)
s2=Mid(cy(m), 1, 1)
If s2=s1 Then
Exit Do
ElseIf s2<s1 Then
i=m+1
Else
j=m-1
End If
Loop
If Then '②
List1.AddItem s+ "— —"+cy(m)
s=cy(m)
Else
List1.AddItem "接不下去了"
flag=False
End If
Loop
End Sub
① ②