首先,编写一个写入数据到数据库的函数,比如
Function AddToDb(Byval s as string)
......
End Function
然后再for i=0 to list1.listcount-1来把每一项list1.list(i)添加到数据库中
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim SqlStr As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Mode=ReadWrite;Persist Security Info=False;Jet OLEDB:Database Password=123"
For i = 0 To List1.ListCount - 1
cn.Execute "INSERT INTO 会员消费 (会员编号) VALUES ('" & List1.List(i) & "');"
Next i
cn.Close
Set cn = Nothing
End Sub