編寫VB程序,實(shí)現(xiàn)如下功能:掃描條形碼,條形碼圖象顯示在圖片框image1中,識(shí)別條形碼,在text1中產(chǎn)生條形碼數(shù)字序列,單擊“國家/地區(qū)”按鈕command1,在標(biāo)簽label1中輸出對(duì)應(yīng)的國家/地區(qū)信息. 前綴碼的相關(guān)信息存放在數(shù)據(jù)庫文件“ean13.a(chǎn)ccdb”的code表中,程序運(yùn)行時(shí)界面如圖所示. 程序代碼如下: Private Sub Command1_Click( ?。?br />Dim cod(1000)As String Dim area(1000)As String Dim s As String,t As String Dim flag As Boolean Dim i As Integer,k As Integer Dim num As Integer,m As Integer s=mid(Text1.Text,1,3)
Dim conn As New ADODB.Connection,rs As New ADODB.Recordset Dim strSQL As String conn.Connectionstring=“Provider=Microsoft.ACE.OLEDB.12.0;Date Source=“+App.Path+“\ean13.a(chǎn)ccdb“ conn.Open strSQL=“select cod,area from code“ Set rs.ActionConnection=conn rs.OpenstrSQL num=0 Do While Not rs.EOF ① cod(num)=rs.Fields(“cod“) area(num)=rs.Fields(“area“) rs.MoveNext Loop rs.Close conn.Close Set rs=Nothing Set conn=Nothing
i=1:flag=False Do While i<=num And flag=False m=Fix((i+num)/2) If cod(m)=s Then ② ElseIf Val(s)<Val(cod(m)) Then num=m-1 Else i=m+1 End If Loop
If flag=False Then Text1.Text=“該前綴不代表國家或地區(qū)“ Else Label1.Caption=area(m) End If End Sub 根據(jù)以上程序代碼,回答下列問題: (1)程序段加框處使用的算法是