【发布时间】:2016-03-08 08:57:48
【问题描述】:
首先,我需要一个答案 (VB.net Try Catch. Keep the Loop after the Catch) 来解决下一个新问题...
阅读上面的链接。我在那里解释一切。
我想为获得Catch 的项目的背景着色,以便我知道其他类型中不存在什么产品。
正在做的是绘制所有ListBox
我在 Form3 中:
ConnectionString.Open()
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
Dim da As OleDbDataAdapter
For i = 0 To Form2.ListBox1.Items.Count - 1
Dim str As String = Form2.ListBox1.Items(i).ToString
Dim col As String = str.Substring(2, 3)
If Form1.MESA_btn.Enabled = False Then
da = New OleDbDataAdapter("SELECT * FROM [Mesa$] WHERE Decor = '" & CB_col.Text & "' and Format([Ref], ""000000000"") like '__" & col & "%'", ConnectionString)
Else
da = New OleDbDataAdapter("SELECT * FROM [Gift$] WHERE Decor = '" & CB_col.Text & "' and Format([Ref], ""000000000"") like '__" & col & "%'", ConnectionString)
End If
da.Fill(dt)
Try
ListBox1.Items.Add(dt.Rows(i).Item(0))
ListBox2.Items.Add(dt.Rows(i).Item(1))
ListBox3.Items.Add(dt.Rows(i).Item(3))
ListBox4.Items.Add(dt.Rows(i).Item(5))
ListBox5.Items.Add(Form2.ListBox5.Items.Item(i))
ListBox6.Items.Add(ListBox4.Items.Item(i) * ListBox5.Items.Item(i))
Catch ex As Exception
Form2.ListBox1.BackColor = Color.Yellow
Form2.ListBox2.BackColor = Color.Yellow
Form2.ListBox3.BackColor = Color.Yellow
Form2.ListBox4.BackColor = Color.Yellow
Form2.ListBox5.BackColor = Color.Yellow
Form2.ListBox6.BackColor = Color.Yellow
End Try
Next
ConnectionString.Close()
这些是程序正在运行的图像(它们已被编辑):
【问题讨论】:
-
设置值的时候为什么不直接画每个列表框的背景呢?那么那些未上漆的(白色)意味着当时发生了错误?
-
但我只想画有错误的那个。这样我就可以看到缺少的产品是什么
-
你能去掉blockquote引起的banner效果吗?谢谢
标签: vb.net listbox listboxitems