vb将text中的内容写入datagrid,急急急 15
首先一下 textbox的内容 是怎么写进去的 如果是直接输入就不用说了,一般是不太好弄,如时是变量写入的话 直接用变量写入datagrid
基本是没有什么难度,如果数少就直接写入,数多的话就用循环写入,也不是什么大问题 ,二话不说上一代码你参考
我这是读取txt文件 写入的
Private Sub Command2_Click()
Lines = ""
Text2.Text = ""
ic = 0
Open "d:\4.txt" For Input As #1
Do While Not EOF(1)
On Error Resume Next
Line Input #1, NextLine
ic = ic + 1
b = Split(NextLine, ",", -1)
If ic = MSFlexGrid1.Rows Then
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
End If
p(ic) = Val(b(0)): X(ic) = Val(b(1)): Y(ic) = Val(b(2)): z(ic) = Val(b(3))
MSFlexGrid1.TextMatrix(ic, 0) = ic
MSFlexGrid1.TextMatrix(ic, 1) = p(ic)
MSFlexGrid1.TextMatrix(ic, 2) = X(ic)
MSFlexGrid1.TextMatrix(ic, 3) = Y(ic)
MSFlexGrid1.TextMatrix(ic, 4) = z(ic)
Lines = Lines & NextLine & Chr(13) & Chr(10)
Picture1.Print X(ic);
If ic Mod 10 = 0 Then Picture1.Print
Loop
Close #1
Text9.Text = Lines
End Sub