if-then-else w/timer

4:06 AM 3/10/2019                            Help Please
Anyone who knows the more complex VBA ?

When I close a file, I have several things I have to do, they are now all done by the VBA. I was able to
figure out. This Timer and the If-then-else seem to be way above my ability.
I now have to remember to detach reference files before sending them in, but when I open and close the .dgn file while making
changes I do not want to detach the reference then. Only upon completion of the .dgn. when I close for the last time
before sending in my work.
This is the simple Macro that detaches the reference file:
Sub XrefDet() 'the () is the ( and ) but it looks funny
' 031019 - Detach Reference file
CadInputQueue.SendCommand "Reference Detach All"

End Sub

So I wanted to have an If-then-else that would time out in say 4-8seconds and it would equal a no
or a strike say space bar and it = no, but you could put Y if you wanted it to detach. I am attaching the
timer from the help file. I could not get to work myself, but this is it.

This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.

Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If

I also looked up the if-then-else and it is also attached.
This example shows both the block and single-line forms of the If...Then...Else statement. It also illustrates the use of If TypeOf...Then...Else.

Dim Number, Digits, MyString
Number = 53 ' Initialize variable.
If Number < 10 Then
Digits = 1
ElseIf Number < 100 Then
' Condition evaluates to True so the next statement is executed.
Digits = 2
Else
Digits = 3
End If

' Assign a value using the single-line form of syntax.
If Digits = 1 Then MyString = "One" Else MyString = "More than one"

Use If TypeOf construct to determine whether the Control passed into a procedure is a text box.

Sub ControlProcessor(MyControl As Control)
If TypeOf MyControl Is CommandButton Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is CheckBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is TextBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
End If
End Sub

These are beyond my ability to under stand, I have tried on my own and spent a number of hours trying to
get something even simple and than build from there. Any Help ? All I can say is thank you and
offer some money for the help.

Parents
  • Anyone who knows the more complex VBA ?

    Remember that VBA is a Microsoft product, not exclusive to MicroStation.  It's available on several different platforms, including the Microsoft Office suite.  Your question is not directly related to MicroStation.  If you search web sites that deal with VBA in general, you may find some hints and tips to get you on your way.  The Excel community is especially active with VBA.

    It is better to implement your task by using MDL

    In this case, MDL would be a step too far, for several reasons.

     
    Regards, Jon Summers
    LA Solutions

  • Jon, thank you for the tip. I plan on going there ASAP . I have also asked a level 1 company programmer for some help. He is not a Micro-Station user but has given many tips on the older bat files and He does some VBA so I am hoping I can gather enough information.

    Barry Lothian gave me a great routine that works for the Detach all. It is really great to get the help and the tips which help. You and Jan have been so valuable. Thanks again 

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

Reply
  • Jon, thank you for the tip. I plan on going there ASAP . I have also asked a level 1 company programmer for some help. He is not a Micro-Station user but has given many tips on the older bat files and He does some VBA so I am hoping I can gather enough information.

    Barry Lothian gave me a great routine that works for the Detach all. It is really great to get the help and the tips which help. You and Jan have been so valuable. Thanks again 

    Version: MicroStation V8i SS 10

    RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus

Children
No Data