几何尺寸与公差论坛

 找回密码
 注册
查看: 680|回复: 0

【转帖】userprogressbar help

[复制链接]
发表于 2009-4-12 22:44:37 | 显示全部楼层 |阅读模式
userprogressbar help
happy new year, api people! i have a macro with a userform. when i click on finish, it takes a good amount of time for the macro to complete its processes. what i would like to do is, when i click on the finish button, use the progress bar in the status bar in solidworks to show the overall progress, as well as update the title during the progress. the example provided in api help is useful, but it doesn't give a clear picture on how to show progress coincident with the macro's progress. other examples use the timer and doevents processes, which i think would complete it, but i don't know exactly how to bring the two concepts together. does anyone have a clear example that would help me perform this operation? your input is greatly appreciated!!
to defeat the wheat, go against the grain.
if you want to use timer, you need to know before, how big "amount of time" would be. because you need to set up upperbound value.
progressbar is only indication of time. choose in your code points where you increase position of pb.
ok, here is the code i have so far:
sub statusbar()
dim x as integer
dim mytimer as double
dim pb as userprogressbar
dim swapp as sldworks.sldworks
dim model as modeldoc2
set swapp = application.sldworks
set model = swapp.activedoc
ptotal = nbi + nib + nrh + nfc
swapp.getuserprogressbar pb
pb.start 0, ptotal, ptitle
for x = 0 to ptotal
pb.updateprogress x
pb.updatetitle ptitle
doevents
loop
pb.end
end sub
ptotal is the total amount of time; each variable added is 250, with a potential total of 1000, depending on what procedures (a total of 4) are ran from user selection. what i want to happen is, for each line of code executed, i want the x in the loop to be incremented by 1 and update the progress of the progress bar. essentially, when the doevents line is executed, it should go back to the other procedure and execute the next line in the other procedure. everytime a line is executed, the loop increments and when all of the procedures have been executed, the progress bar should finish at 100%. or is this the wrong application of doevents? how can i accomplish this incrementation for each line of code executed elsewhere in my project? please advise.
thank you!!
to defeat the wheat, go against the grain.
you can set a max value for the progressbar (for example 100 if you have 100 code lines). then set the value from the pgbar to 0. now raise the value of the pgbar always for one point after each code line. i have to say that this is the way in vb.net but i think its near the same way in visual basic i think.
this is what i have hope it helps.
i check all the parts of the assembly and the progress bar fills according to how many parts are left to check.
'set count according to how many parts in assebmly
frmprogress.progressbar1.max = swass.getcomponentcount(false) - 1
'loop through all parts
for i = 0 to swass.getcomponentcount(false) - 1
'progressbar updates in every loop
frmprogress.progressbar1.value = i
next i
hope its not to confusing.
solidworks 2006,2007,2008,2009 (office premium.)
core 2 duo e6850 @ 3.00 mhz
window xp pro sp3 32 bit
ati firegl v7350
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 22:12 , Processed in 0.034069 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表