。 (2)請在橫線處填入合適的代碼。 Dim n As Integer Dim xh(1 To 40)As Integer,xm(1 To 40)As String,cj(1 To 40)As Integer Private Sub Command1_Click ( ?。?br />'本過程在文本框 Text1 中輸入班級名稱,從數據庫中讀取指定班級的學號、姓名和成績的'數據分別存儲在數組 xh,xm 和 cj 中 Dim conn As New ADODB.Connection conn.ConnectionString=“provider=microsoft.ace.jye.ai.12.0;data source=″ +App.Path+″\js.jye.ai″ conn.Open Dim rs As New ADODB.Recordset rs.ActiveConnection=conn rs.Open″select*from 技術″ '本過程的其他語句略 End Sub Private Sub Command2_Click ( ) Dim wz(1 To 40)As Integer Dim i As Integer,j As Integer List2.AddItem“學號″&″″&″姓 名″&″″&″成績″&″″&″位置″ For i=1 To n ① Next i For i=1 To n For j=1 To n If ②Then wz(i)=wz(i)+1 End If Next j List2.AddItem adj(Str(xh(i)))+adj(xm(i))+adj(Str(cj(i)))+adj(Str(wz(i))) Next i End Sub Function adj(c As String) As String'固定輸出 5 個字符長度 Dim i As Integer ③ For i=1 To 5-Len(c) adj=adj+″″ Next i End Function
1.大部分社交軟件都有好友推薦的功能,當用戶 A 和用戶 B 的共同好友數量超過閾值 p 時,由系統向用戶 A 推薦用戶 B。 編寫 VB 程序,實現好友推薦功能。運行程序,列表框 Listl 中顯示用戶 id 及好友列表,在文本框 Textl 中 輸入推薦目標用戶 id,在文本框 Text2 中輸入閾值 p,點擊“推薦”按鈕,在列表框List2 中顯示用戶之間的關系,在標簽 Label5 中顯示向目標用戶推薦的好友列表。程序運行界面如圖: (1)根據如圖所示數據,若輸入用戶 id 為“3”,輸入閾值為“3”,則推薦好友為: