请教datagrid问题

caoyang0299 2013-03-25 12:28:38
datagrid我单机表格中的某一行,将某一行的数据插入到新表里
现在的问题是,我单击的时候,msgbox显示的数据是正确的,但datagrid里数据会变,都变成cinvcode了,第二个,在点击command是,ss(2)能显示数值,ss(0),ss(1)都没值是怎么回事,
我这是个三列的datagrid,哪位大侠帮看看,谢谢!
Private Sub Command2_Click()
Dim conn As New ADODB.Connection
Dim strc As String
strc = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=erp;Data Source=127.0.0.1"
conn.Open strc

Dim strsql As String
MsgBox (ss(2))
'strsql = "insert into tt(cinvname,cinvstd) values (" & ss(1) & "," & ss(2) & ")"
'conn.Execute (strsql)

End Sub

Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
bm = DataGrid1.Row
k = DataGrid1.Columns.Count
For ic = 0 To k - 1
ReDim ss(ic)
DataGrid1.Row = bm
DataGrid1.Col = ic
ss(ic) = DataGrid1.Text

MsgBox (ss(ic))

Next ic

End Sub
...全文
280 点赞 收藏 1
写回复
1 条回复
dong_y888 2013年03月25日
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
   bm = DataGrid1.Row
   k = DataGrid1.Columns.Count
   ReDim ss(k)  '改这里
   For ic = 0 To k - 1
     DataGrid1.Row = bm
     DataGrid1.Col = ic
     ss(ic) = DataGrid1.Text
      MsgBox (ss(ic))
  Next ic
End Sub
回复 点赞
发动态
发帖子
VB基础类
创建于2007-09-28

2744

社区成员

19.7w+

社区内容

VB 基础类
社区公告
暂无公告