vb 中如何在Form2表单中提交数据

来源:百度知道 编辑:UC知道 时间:2024/06/09 03:10:12
最近在做个电话本,调用到form2表单提交出错,请高手指点一下
Private Sub Command1_Click()
'将文本框中的信息添加到列表框中
Dim i As Integer
With ListView1.ListItems.Add()
.Text = Text1(0)
For i = 1 To 5
.SubItems(i) = Text1(i)
Next i
End With
MsgBox "添加成功!", vbOKOnly + vbInformation, "系统信息"
Private Sub Form_Load()
Dim tpStr As String, i As Integer
fileName = App.Path & "\data.txt"
If Dir(fileName) <> "" Then
'加载数据
Open fileName For Input As #1
Do While Not EOF(1)
With ListView1.ListItems.Add()
For i = 0 To 5
Line Input #1, tpStr
If i = 0 Then
.Text = tpStr
Else
.SubItems(i) = tpStr
End If
Next i
End With
Loop

如果是在form1中调用form2的数据和控件,那么需要在form2的控件名前加上form2
比如form2.tplist.subitems(i)

哪里出错?
还有你的data.txt文件的数据格式是怎么样的呢

以上表单在form1可以用,如果要在form2用,语句如何写,请高手指点谢谢