此问题是MSHFlexrid的字段内容添加到ACCESS数据库问题,添加格式如下如
01
02
03
04
05
06
08
01
03
05
06
08
01
15 这么一个MSHFlexGrid的一个列内容向ACCESS数据库里的第一字段内添加成01
02 02
03 03 03
04 04 04 04
05 05 05 05
06 06 06 06
08 08 08 08
01 01 01 01
03 03 03 03
05 05 05 05
06 06 06 06
08 08 08 08
01 01 01 01
15 15 15 15 这个怎么做呢
Dim TextLine
Dim strFileName As String
Dim a() As String
Dim i As Integer
Dim j As Integer
With MSFlexGrid1
.Rows = 20
.Cols = 6 strFileName = App.Path & "\testdata3.txt" Open strFileName For Input As #1 ' 打开文件。 .Col = 1
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
i = i + 1
.Row = i
.Text = TextLine
Loop Close #1 ' 关闭文件。
End WithEnd Sub
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i As Integer
Dim intCount As Integer
Dim intEndRow As Integer
Dim intStart As Integer cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\mydb.mdb;Persist Security Info=False" rs.Open "select * from table3", cn, adOpenStatic, adLockOptimistic With MSFlexGrid1
.Col = 1
For i = .Rows - 1 To 1 Step -1
.Row = i If Trim(.Text) <> "" Then
intEndRow = i
Exit For
End If
Next i If intEndRow > 0 Then
For i = 1 To intEndRow
.Row = i
strTemp = ""
For j = 1 To i
strTemp = strTemp & IIf(j > 1, " ", "") & .Text
Next j
rs.AddNew
rs.Fields(1) = strTemp
rs.Update
Next i
End If
End With
rs.Close
cn.Close
Set rs = Nothing
Set cn = NothingEnd Sub