Message Box

Message Box

Anonymous
Not applicable
1,315 Views
14 Replies
Message 1 of 15

Message Box

Anonymous
Not applicable
Hi All,

I have an application that takes a couple of seconds to run (approx. 30-40 seconds, it has a lot of code to iterate thru) (plus i'm not the best programmer) what I want to do is have a msgbox up on the screen stating to wait a second then have it automatically switch off at the end of the process. Is there a way to do this? right now the code stops for me to hit the "OK" button. I was also trying to avoid making another userform and firing it.Any help would be appreciated...

Thanks,
Bill
0 Likes
1,316 Views
14 Replies
Replies (14)
Message 2 of 15

Anonymous
Not applicable
You'll need to make another form. A message box is modal, which means
everything stops and waits for it to be dismissed. For your own forms you
can choose whether they're modal or modeless. You'll want a modeless form.
--
Brian Ekins
Autodesk Inventor API

wrote in message news:5455201@discussion.autodesk.com...
Hi All,

I have an application that takes a couple of seconds to run (approx. 30-40
seconds, it has a lot of code to iterate thru) (plus i'm not the best
programmer) what I want to do is have a msgbox up on the screen stating to
wait a second then have it automatically switch off at the end of the
process. Is there a way to do this? right now the code stops for me to hit
the "OK" button. I was also trying to avoid making another userform and
firing it.Any help would be appreciated...

Thanks,
Bill
0 Likes
Message 3 of 15

Anonymous
Not applicable
Or how about changing the mouse pointer to an hourglass while the iteration is running?
0 Likes
Message 4 of 15

Anonymous
Not applicable
Why not use a progress bar?

--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 5 of 15

Anonymous
Not applicable
I keep meaning to try one of those but have never got round to it..
0 Likes
Message 6 of 15

Anonymous
Not applicable
Thanks for the replies.... I kind of figured that I could not use a standard msgbox. I think using an hour glass is a good idea, I think I know how to change the cursor to an hour glass. How do I use/construct a progress bar? I have another question, is there a way that you can turn off the visibility of my userform while my modual is running? I used

"User_Form_Part_Selection_V1.hide"

It seems that the code runs to fast for it to actually hide, it's like the switch does not have time to execute.... It hides if I step thru the code. Thanks for the help!

Bill
0 Likes
Message 7 of 15

Anonymous
Not applicable
See attachment!

--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 8 of 15

Anonymous
Not applicable
Teun,

Thanks for the snippet of code... I unfortunately don't have VB, I only have VBA with IV. Thanks for the info. though.

Bill
0 Likes
Message 9 of 15

Anonymous
Not applicable
Bill,

Fortunately for you the code of the example is also easily to read by opening the vbp file with notebook.
You can changes the status of the progressbar by raising the value in once or with steps by placing these raises in different parts of your code.
When iterating through lists using For Each you cain raise the value with each lines of the list.

Matthijs
0 Likes
Message 10 of 15

Anonymous
Not applicable
Matthijs,

Thanks for the reply. I was going simply off of what one of the IT guy's here told me. He has VB programming training, he told me that I could not do it in VBA. I do not have a lot of seat time programming (on in IV's VBA) and I am learning everyday. I did open the files with notepad and can follow the logic behind the code. I'm not sure I fully understand how to modify the code to work for me. I might be off on this but if I read the code loosely (not knowing VB) do it work like this...

when the start button is clicked it creates a userform setting the properties, then sets the properties of the "progressbar". then it would seem to iterate through a loop where the progress bar increases by 1 until it completes the loop, then evokes a msgbox "Done!"?

I think I kind of understand what it is doing even if my description is not that clear, what I'm fuzzy on is how do you increase "the little blue bar" by 1 in VBA and I'm not sure what you were referring to with "You can changes the status of the progressbar by raising the value in once or with steps by placing these raises in different parts of your code. "

Thanks for your help
Bill
0 Likes
Message 11 of 15

Anonymous
Not applicable
Bill,
Maybe your IT guy has just got the basic VBA training. When in MS VBA screen select Tools-->Additional Controls and select Microsoft Prograssbar Control 6.0. This will add this function in your toolbar. So it seems to me like you can use it.

I have copied the example from Teun into VBA and added an extra button. The first is when used something like "For Each", it raises the bar smoothly. The second button illustrates a less smooth raise, but raises the value with steps.

Matthijs
0 Likes
Message 12 of 15

Anonymous
Not applicable
very easy way, use the status bar

-----------------------------------------------------------------

' Get the Inventor Object, if Inventor is not running, start the application
'
Public Function GetInventor(Optional bCreateApp As Boolean = True) As Inventor.Application

On Error Resume Next
Set GetInventor = GetObject(, "Inventor.Application")
If Err Then
Err.Clear

If bCreateApp Then
' ask user to start Inventor
Dim iAns As Integer
iAns = MsgBox("Inventor is not currently running. Would you like to start the program?", vbYesNo)

If iAns = vbYes Then
Set GetInventor = CreateObject("Inventor.Application")
If Not GetInventor Is Nothing Then
GetInventor.visible = True
End If
End If
Else
Set GetInventor = Nothing
End If

End If
On Error GoTo 0

End Function


Public Sub MyMacro()

Dim oIV as Inventor.Application
Set oIV = GetInventor

Dim sStatus as String
set sStatus = oIV.StatusBarText 'save old status text
oIV.StatusBarText = "Running macro, please wait..."

' do macro

oIV.StatusBarText = sStatus 'put original status text back

End Sub
0 Likes
Message 13 of 15

Anonymous
Not applicable
I am not sure it is 100% legal to use the progress bar in VBA, and maybe
that is why the IT guy said you can't do it.

Here is a way to fake it in VBA.... it is a little more work, especially
since VBA doesn't do arrays of controls, but ... for what its worth.

--
___________________
Kent Keller
www.kwikmcad.com


wrote in message news:5460533@discussion.autodesk.com...
Matthijs,

Thanks for the reply. I was going simply off of what one of the IT guy's
here told me. He has VB programming training, he told me that I could not do
it in VBA. I do not have a lot of seat time programming (on in IV's VBA) and
I am learning everyday. I did open the files with notepad and can follow the
logic behind the code. I'm not sure I fully understand how to modify the
code to work for me. I might be off on this but if I read the code loosely
(not knowing VB) do it work like this...

when the start button is clicked it creates a userform setting the
properties, then sets the properties of the "progressbar". then it would
seem to iterate through a loop where the progress bar increases by 1 until
it completes the loop, then evokes a msgbox "Done!"?

I think I kind of understand what it is doing even if my description is not
that clear, what I'm fuzzy on is how do you increase "the little blue bar"
by 1 in VBA and I'm not sure what you were referring to with "You can
changes the status of the progressbar by raising the value in once or with
steps by placing these raises in different parts of your code. "

Thanks for your help
Bill
0 Likes
Message 14 of 15

Anonymous
Not applicable
Actually after I posted, it dawned on me that you would probably want to
have all the image boxes turn on all at once and then change the back color
as it progresses. That way the user would see how far from the end he is.
Same basic concept though.

--
___________________
Kent Keller
www.kwikmcad.com
0 Likes
Message 15 of 15

Anonymous
Not applicable
Guy's,

Thanks for all of the input... This is one of those things that now that I can see how easily it can be accomplished. In my working with VBA I have learned enough to accomplish the tasks I want to automate, unfortunately that does not allow the opportunity to branch out an figure other things out. I would have never thought of either of these progress bars. Thanks for sharing... I have a couple more questions... I'll save them for a new post after I do a search. I am working a project deadline so it may be a few day's...

Thanks again,
Bill
0 Likes