嗨,我对进度条有些陌生,因此我不确定如何将其合并到循环中。我正在尝试做的是,在每个循环中,进度条都会增加其值或在我的功能已完成的百分比上取得进展。谢谢您能帮助我在此处添加一些代码。预先非常感谢。
这是我正在处理的循环:
If reader.HasRows Then
While reader.Read()
DataTableName = TextBox1.Text
ID1 = reader.Item("MotorSN").ToString
ID2 = reader.Item("StationNo").ToString
ID3 = reader.Item("WU_NestNo").ToString
ID4 = reader.Item("PT_TimeIn").ToString
ID5 = reader.Item("PT_NestNo").ToString
ID6 = reader.Item("PT_Q_Std_Bellmouth_0").ToString
ID7 = ""
ID8 = ""
ID9 = ""
ID10 = ""
ID11 = ""
ID12 = ""
Note1 = ""
Note2 = ""
sDate = ""
sTime = ""
wd = S2K_SetDataTableVariableValue(DataTableName, dValue, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, ID10, ID11, ID12, Note1, Note2, sDate, sTime)
End While
MessageBox.Show("Data has been written To the table")
End If
答案 0 :(得分:0)
与我实施的类似,它很容易。
datatable.rows.count
或类似内容ProgressBar1.Maximum = datatablerowcount
ProgressBar1.Step = 1
上将步长设置为1。end while
添加到此ProgressBar1.PerformStep()
之前添加这基本上是将进度条的全部值设置为您必须阅读的项目数量,然后在每次读取的行中都将最大值接近该最大值。
修改
Dim row_count As Integer = datatable.Rows.Count '(or however you can)
ProgressBar1.Maximum = row_count
ProgressBar1.Step = 1
If reader.HasRows Then
While reader.Read()
DataTableName = TextBox1.Text
ID1 = reader.Item("MotorSN").ToString
ID2 = reader.Item("StationNo").ToString
ID3 = reader.Item("WU_NestNo").ToString
ID4 = reader.Item("PT_TimeIn").ToString
ID5 = reader.Item("PT_NestNo").ToString
ID6 = reader.Item("PT_Q_Std_Bellmouth_0").ToString
ID7 = ""
ID8 = ""
ID9 = ""
ID10 = ""
ID11 = ""
ID12 = ""
Note1 = ""
Note2 = ""
sDate = ""
sTime = ""
wd = S2K_SetDataTableVariableValue(DataTableName, dValue, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, ID10, ID11, ID12, Note1, Note2, sDate, sTime)
progressbar1.performstep()
End While
MessageBox.Show("Data has been written To the table")
End If
编辑
不能100%确定您从其他书本中读取的内容。但是,是的,您只是从阅读器中读取了您所读取的书中的内容并将其设置为row_count