【发布时间】:2013-02-27 20:19:06
【问题描述】:
我的代码有问题;并希望能得到一些帮助,让她做我想做的事,而不会出现烦人的错误。读取数据绑定列表框字符串,找到用户选择的字符串并将所述字符串写入文件。
Private Sub btnContinue_Click(sender As System.Object, e
As System.EventArgs) Handles btnContinue.Click
' 1st file and mySQL Update to testing table
If txtLocation.Text.ToString <> "" And txtUnitTested.Text.ToString <> "" Then
Dim filewriter As New System.IO.StreamWriter(
"C:\Users\OER\Documents\Visual Studio 2010\Projects\frmTest1_0.txt")
Dim curItem = lstCustomer.SelectedItem
Dim now As DateTime = DateTime.Now
With filewriter
.WriteLine(vbCrLf + (now.ToString("F"))) ' Write the DateTime to the file
End With
For Each objDataRowView As DataRowView In lstCustomer.SelectedItems
Dim item As String
For Each item As DataRowView In Me.lstCustomer.Items.Item("customer")
item = String.Parse(lstCustomer.SelectedValue)
WriteLine(curItem(item))
Next item
Next ' THIS IS THE FOR LOOP I AM HAVING ISSUES WITH!!!!!!!
With filewriter
.WriteLine(vbCrLf + txtLocation.Text + vbCrLf + txtUnitTested.Text)
End With
filewriter.Close()
frmTest1.Show()
Else
MsgBox("Please Type the Location and Unit Tested!!!", vbCritical)
txtLocation.Clear()
txtUnitTested.Clear()
txtLocation.Focus()
End If
【问题讨论】:
-
你得到了什么“恼人的错误”?我怀疑它是
HavingIssueException。 -
不,先生,更多的是逻辑错误(程序将 System.Data.DataView 添加到我的数据库中)
-
就好像列表框中的数据需要单独声明或者与数据绑定列表一起声明,可以这么说
-
是的,上面有逻辑问题。但是,你能显示加载 ListBox 的代码吗?
-
错误是
标签: vb.net vb.net-2010 filewriter databound-controls