1 / 2

Public Function SiloVolume1(h, hc, R) Dim rc As Single Dim pi As Single

Here’s a sample function showing the use of the If then / else / end if construct. Function computes the volume of material in cone bottom silo. The silo’s radius is R, the height of the cones section is hc, and the height of the material in the silo is h. Units are assume to be consistent.

quynh
Download Presentation

Public Function SiloVolume1(h, hc, R) Dim rc As Single Dim pi As Single

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Here’s a sample function showing the use of the If then / else / end if construct. Function computes the volume of material in cone bottom silo. The silo’s radius is R, the height of the cones section is hc, and the height of the material in the silo is h. Units are assume to be consistent. Public Function SiloVolume1(h, hc, R) Dim rc As Single Dim pi As Single pi = WorksheetFunction.pi() SiloVolume1 = 0# If h < hc Then rc = h * R / hc SiloVolume1 = (1 / 3) * pi * rc ^ 2 * h Else SiloVolume1 = (1 / 3) * pi * R ^ 2 * hc + pi * R ^ 2 * (h - hc) End If ' and check to make sure h was => 0 If h < 0 Then SiloVolume1 = "Error -- h must be > 0" End Function

  2. Some Form items “Sub”s are created for each object on the form. When viewing the code, the drop down list in left panel shows the items in the form and the list box in the right hand panel gives the various methods associated with the selected object. “Declaration s” can be found at the top of the drop down list in the left panel. When you compute a new value for R and set the text with the “plabel & v label /…” string, it should be assigned to lblR.caption, not just lblR ( or whatever you called your label box). The macro to run the form must be in a module, not in the form. So Insert / Module then Insert / Procedure and select Sub.

More Related