怎样获得程序执行的时间,并用ProgressBar表现出来

gufengsheng 2004-04-09 04:39:54
怎样获得程序执行的时间,并用ProgressBar表现出来,
有点点IE浏览器的效果.
...全文
205 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
win2000admin 2004-04-14
  • 打赏
  • 举报
回复
ProgressBar???是ALL里的part显示,你要的时间好象不是!!!
求时间直接用变量-就好了!
tangxiaosan001 2004-04-12
  • 打赏
  • 举报
回复
关注.
Rozre 2004-04-09
  • 打赏
  • 举报
回复
up
daisy8675 2004-04-09
  • 打赏
  • 举报
回复
給你個exp:

Private Sub cmd_search_Click()

'讀取資料
If make_connection = False Then
MsgBox (db_err)
Unload Me
End If

Dim g_sql As String

If opt_1.Value = True Then
g_sql = "select distinct area,ck_name,cp_name from c_cust order by area,ck_name,cp_name"
End If

If opt_3.Value = True Then
g_sql = "select distinct cp_name,area,ck_name from c_cust order by cp_name,area,ck_name"
End If

If make_i(g_sql) = flase Then
MsgBox (db_err)
Unload Me
End If

Dim cat1 As String: cat1 = ""
Dim cat2 As String: cat2 = ""
Dim cat3 As String: cat3 = ""

'TreeView 引用方法
'nodes.add 親子, 親子關係,索引鍵,文字,示意圖,被選取的圖示

TreeView1.Nodes.Clear ' 清空 TreeView

'第零層
TreeView1.Nodes.Add , , "電話簿", "電話簿", "ROOT"

Do While Not rs1.EOF
If rs1(0) <> cat1 Then ' 第一層
TreeView1.Nodes.Add "電話簿", tvwChild, rs1(0), rs1(0), "ROOT"
cat1 = rs1(0)
End If
If rs1(0) = cat1 And rs1(1) <> cat2 Then '第二層

TreeView1.Nodes.Add cat1, tvwChild, cat1 + rs1(1), rs1(1), "CHILD"
cat2 = rs1(1)
End If
If rs1(0) = cat1 And rs1(1) = cat2 And rs1(2) <> cat3 Then '第三層
TreeView1.Nodes.Add cat1 + cat2, tvwChild, cat1 + cat2 + rs1(2), rs1(2), "CHILD"
cat3 = rs1(2)
End If

rs1.MoveNext
Loop


'讀取資料並 Show 於 Datagrid
g_sql = "select c_cust.cust_name,c_cust.area,c_cust.ck_name,c_cust.cp_name, c_lman2.l_class,c_lman2.L_name,c_lman2.L_tel" & _
" from c_cust ,c_lman2 where c_cust.cust_no=c_lman2.custno"
rs1.Close
If make_i(g_sql) = flase Then
MsgBox (db_err)
Unload Me
End If

With MSFlexGrid1
.Rows = 2
.Row = 0
.Col = 0
.ColWidth(0) = 1400
.Text = "公司名稱"
.Col = 1
.ColWidth(1) = 1400
.Text = "職稱"
.Col = 2
.ColWidth(2) = 1400
.Text = "稱謂"
.Col = 3
.ColWidth(3) = 2000
.Text = "電 話"
.ColWidth(4) = 0 ' 隱藏的欄位

End With

Dim a_cnt As Integer: a_cnt = 0
Do While Not rs1.EOF
a_cnt = a_cnt + 1
rs1.MoveNext
Loop
rs1.MoveFirst
'顯示進度的 Status Bar
fra_loaded.Visible = True
ProgressBar1.Max = a_cnt
ProgressBar1.Min = 0
ProgressBar1.Value = 0
Do While Not rs1.EOF

DoEvents
With MSFlexGrid1
' row 的啟始值為 0, column 的啟始值也是 0
.Row = .Rows - 1
.Col = 0
.Text = rs1("cust_name")
.Col = 1
.Text = IIf(IsNull(rs1("l_class")), "", rs1("l_class"))
.Col = 2
.Text = rs1("l_name")
.Col = 3
.Text = IIf(IsNull(rs1("l_tel")), "", rs1("l_tel"))

'放入後續的查核用的資料
.Col = 4
If opt_1.Value = True Then
.Text = rs1("area") & rs1("ck_name") & rs1("cp_name")
End If
If opt_3.Value = True Then
.Text = rs1("cp_name") & rs1("area") & rs1("ck_name")
End If

.Rows = .Rows + 1
End With

ProgressBar1.Value = ProgressBar1.Value + 1

rs1.MoveNext
Loop

fra_loaded.Visible = False



End Sub
lxqlogo0 2004-04-09
  • 打赏
  • 举报
回复
程序开始执行时,将当时的时间赋值给一个变量,然后在程序执行结束再记住当时的时间,两个时间相减就是程序的执行时间。
ColdMooon 2004-04-09
  • 打赏
  • 举报
回复
怎样获得程序执行的时间,并用ProgressBar表现出来,

ProgressBar表示的是进度,不是时间。

IE浏览器的进度条也不是匀速的走的。
kmzs 2004-04-09
  • 打赏
  • 举报
回复
如果是循环可通过次数控制
songq 2004-04-09
  • 打赏
  • 举报
回复
关注

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧