Jump to content


VBA coding questions


  • Please log in to reply
1 reply to this topic

#1 VROSA

VROSA

    Ghost Member

  • Global Moderator
  • PipPipPipPipPip
  • 2,043 posts
  • Location:Belo Horizonte - Minas Gerais - Brazil
  • Interests:Hardware, Software, Alphas and Betas, OS Mods, Windows 8.1, Windows 10, Linux, Games, Fun, Friends.
  • Country:Brazil

Posted 17 February 2010 - 09:27 PM

I'm developing a VBA application for calculation of wedge failure probabilities in open-mine slopes. It's part of my mastering project in geotechnical science. The core modules are working fine and the job is being done correctly, but today I found a small bug that is bothering me.

After the calculation is done the results have to be saved in two log files. For that, a folder must be chosen, but if I click in the "Cancel" button of the "Browse" dialog, Excel crashes. I have other ways to do that, but what bothers me is that it should work, 'cos I have already used this piece of code without probs, though I'm currently using Excel 2010.

Here is the bad code: Attached File  SelectFolder.zip   1.15K   1 downloads

Any thoughts ?

~update~

Workarrounded.

:cheers:

#2 VROSA

VROSA

    Ghost Member

  • Global Moderator
  • PipPipPipPipPip
  • 2,043 posts
  • Location:Belo Horizonte - Minas Gerais - Brazil
  • Interests:Hardware, Software, Alphas and Betas, OS Mods, Windows 8.1, Windows 10, Linux, Games, Fun, Friends.
  • Country:Brazil

Posted 20 February 2010 - 01:01 PM

GIVE A HAND ON THAT !

I've just finished the one of the main modules of my VBA application. It's responsible for a hard work and it's giving correct results, but I feel that it's not well polished yet. The code is a bit bloated, I think. Is there some app that can evaluate the efficiency of a VBA code? I know how to do that in VB and VB.Net, but not in VBA.

But what exactly does the code do and what must be perfected ? :cheers:

Consider a given rock mass with some discontinuities and a slope cut on that. Some discontinuities planes may become unstable and slip or may intercept one to each other forming wedges that can also slip, but it depends of factors such as friction angle of the materials (rock), slope inclination, wedge line direction and inclination and slope line direction, among other things. There are three main types of slipping: Planar, Wedge and Flexural. In this piece of code I'm considering just the last two.

The first thing to be done is to convert the discontinuites attitudes to pole attitudes and then convert them to director cosines. Once it's done the possible intersections must be calculated. It'a a kind of combinatory analysis that may generate a very large amount of data, depending of the mumber of initial planes. Just to ilustrate, a dataset with 1000 initial planes may result in more than 500000 (half a million) possible intersections. During this process some invalid intersections are excluded.

After intersection calculation all generated data must be converted to attitude again, and then pass throught a quadrant correction. At this point the failure criteria can be applied to determine which intersections may represent a problem for slope design. As stated above two criteria are being considered: Wedge and Flexural.

Every entry in the intersections dataset must then be checked and if it fails a counter is incremented by 1. In the case of the flexural analysis, the slope must be varied from a initial value to 90º. It's done by using two "For Next" structures, one to move throught the intersections dataset and one for the slope value variation. This is the part of the code that must be rewritten for performance improvement. It's taking too much time to complete the loop. I thought of making the slope variation backwards (from 90 to min. value), because what doesn't fail with a 90º slope won't fail with less inclined ones. This way I could remove some intersections from the subsequent checks, saving CPU clocks.

I'm hardworking on that but still didn't find a reasonable way to do that. If you have some ideas, please give me a hand !

File: Attached File  WedgeCounter_Rev4.zip   648.13K   0 downloads

~edited~

Done :cheers:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users