1 / 69

Part 3. Description of a function code

Part 3. Description of a function code. Part 3. Description of a function code. As an example we will write a function code to find the outside diameter of a carbon steel pipe, with input nominal diameter in inches. Part 3. Description of a function code.

marilu
Télécharger la présentation

Part 3. Description of a function code

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. Part 3. Description of a function code

  2. Part 3. Description of a function code As an example we will write a function code to find the outside diameter of a carbon steel pipe, with input nominal diameter in inches.

  3. Part 3. Description of a function code As an example we will write a function code to find the outside diameter of a carbon steel pipe, with input nominal diameter in inches. The name of the function will be

  4. Part 3. Description of a function code As an example we will write a function code to find the outside diameter of a carbon steel pipe, with input nominal diameter in inches. The name of the function will be "Pipe_Imp_CS_Dext_dn_sch"

  5. Part 3. Description of a function code As an example we will write a function code to find the outside diameter of a carbon steel pipe, with input nominal diameter in inches. The name of the function will be "Pipe_Imp_CS_Dext_dn_sch" This function is based on outside diameters defined in ASME B36.10M

  6. Part 3. Description of a function code As an example we will write a function code to find the outside diameter of a carbon steel pipe, with input nominal diameter in inches. The name of the function will be "Pipe_Imp_CS_Dext_dn_sch" This function is based on outside diameters defined in ASME B36.10M A table with the outside diameters "dext [mm]", corresponding to the nominal diameters "dn [in]", should be included on a sheet in the Excel file. The function will read the information from this sheet.

  7. The following table shows outside diameters and thicknesses for carbon steel pipes of different nominal diameters and schedules, according to the standard ASME B36. 10

  8. Function code for the exterior diameter

  9. Function code for the exterior diameter As explained in Part 1, the code starts by defining the function name and Visual Basic adds the "End Function".

  10. Function code for the exterior diameter As explained in Part 1, the code starts by defining the function name and Visual Basic adds the "End Function". Function Pipe_Imp_CS_Dext_dn(Dn) End Function

  11. The exterior diameter depends only on the nominal diameter (Dn) and is in the third column of the table.

  12. The code begins by defining the matrix "C" containing rows 1 through 36 and columns 1 through 3.

  13. Matrix "C" in whose third column from rows 7 to 36 are the exterior diameters "OD [mm]"

  14. Next, it will be defined in the code, the array dimension of "C"

  15. Function Pipe_Imp_CS_Dext_dn(Dn) Dim C(36, 3) End Function

  16. Function Pipe_Imp_CS_Dext_dn(Dn) Dim C(36, 3) End Function The matrix C is defined with 36 columns and 3 rows

  17. Reading of the table

  18. Reading of the table To read the information in the table, one uses a structure called For-next

  19. Reading of the table To read the information in the table, one uses a structure called For-next The For-next indicates to repeat an operation that depends on an index "m" and indicates the start and end values ​​of "m".

  20. Reading of the table To read the information in the table, one uses a structure called For-next The For-next indicates to repeat an operation that depends on an index "m" and indicates the start and end values ​​of "m". For m = 1 To 36

  21. Reading of the table To read the information in the table, one uses a structure called For-next The For-next indicates to repeat an operation that depends on an index "m" and indicates the start and end values ​​of "m". For m = 1 To 36 In this space are introduced the operations to be performed, which depend on the temporal value of the index "m"

  22. Reading of the table To read the information in the table, one uses a structure called For-next The For-next indicates to repeat an operation that depends on an index "m" and indicates the start and end values ​​of "m". For m = 1 To 36 In this space are introduced the operations to be performed, which depend on the temporal value of the index "m" The operations with the index "m" end with

  23. Reading of the table To read the information in the table, one uses a structure called For-next The For-next indicates to repeat an operation that depends on an index "m" and indicates the start and end values ​​of "m". For m = 1 To 36 In this space are introduced the operations to be performed, which depend on the temporal value of the index "m" The operations with the index "m" end with Next m

  24. Reading of the table To read the information in the table, one uses a structure called For-next The For-next indicates to repeat an operation that depends on an index "m" and indicates the start and end values ​​of "m". For m = 1 To 36 In this space are introduced the operations to be performed, which depend on the temporal value of the index "m" The operations with the index "m" end with Next m The loop ends after the operation with index "m = 36" is performed.

  25. The “ For-next” is programed as follows

  26. The “ For-next” is programed as follows

  27. The “ For-next” is programed as follows This indicates that cells in column 3, from row 1 to 36, shall be read

  28. The “ For-next” is programed as follows This indicates that cells in column 3, from row 1 to 36, shall be read

  29. The “ For-next” is programed as follows This indicates that cells in column 3, from row 1 to 36, shall be read The read value is assigned to the element (m, 3) of the matrix "C"

  30. The “ For-next” is programed as follows This indicates that cells in column 3, from row 1 to 36, shall be read The read value is assigned to the element (m, 3) of the matrix "C"

  31. The “ For-next” is programed as follows This indicates that cells in column 3, from row 1 to 36, shall be read The read value is assigned to the element (m, 3) of the matrix "C" The reading is done in the sheet that has been named 6.CS_Imp

  32. The “ For-next” is programed as follows This indicates that cells in column 3, from row 1 to 36, shall be read The read value is assigned to the element (m, 3) of the matrix "C" The reading is done in the sheet that has been named 6.CS_Imp

  33. The “ For-next” is programed as follows This indicates that cells in column 3, from row 1 to 36, shall be read The read value is assigned to the element (m, 3) of the matrix "C" The reading is done in the sheet that has been named 6.CS_Imp On sheet "6.CS_Imp" it must be read the contents of the cell (m, 3)

  34. Summary of programming steps

  35. Summary of programming steps Function

  36. Summary of programming steps Function Pipe_Imp_CS_Dext_dn(Dn) End Function

  37. Summary of programming steps Function Pipe_Imp_CS_Dext_dn(Dn) Dim C(36, 3) End Function

  38. Summary of programming steps Function Pipe_Imp_CS_Dext_dn(Dn) Dim C(36, 3) For m = 1 To 36 End Function

  39. Summary of programming steps Function Pipe_Imp_CS_Dext_dn(Dn) Dim C(36, 3) For m = 1 To 36 C(m, 3) = thisWorkbook.Worksheets("6.CS_Imp").Cells(m, 3).Value End Function

  40. Summary of programming steps Function Pipe_Imp_CS_Dext_dn(Dn) Dim C(36, 3) For m = 1 To 36 C(m, 3) = thisWorkbook.Worksheets("6.CS_Imp").Cells(m, 3).Value Next m End Function

  41. Identification of the row in which each nominal diameter is found

  42. Identification of the row in which each nominal diameter is found By associating the nominal diameter to its row in the matrix, one knows the row where the rest of the data related to this diameter is located in the matrix.

  43. Identification of the row in which each nominal diameter is found By associating the nominal diameter to its row in the matrix, one knows the row where the rest of the data related to this diameter is located in the matrix. En el código se agrega la siguiente línea

  44. Identificación de la fila en que se encuentra cada diámetro nominal Al asociar el diámetro nominal del caso a su fila en la matriz, se conoce la ubicación de la fila de ”todos los datos correspondientes a ese diámetro”. En el código se agrega la siguiente línea If Dn = 0.5 Then x = 7

  45. Identificación de la fila en que se encuentra cada diámetro nominal Al asociar el diámetro nominal del caso a su fila en la matriz, se conoce la ubicación de la fila de ”todos los datos correspondientes a ese diámetro”. En el código se agrega la siguiente línea If Dn = 0.5 Then x = 7 Cuyo significado es Si Dn tiene el valo 0.5 [in] entonces se trata de la fila 7

  46. Identificación de la fila en que se encuentra cada diámetro nominal Al asociar el diámetro nominal del caso a su fila en la matriz, se conoce la ubicación de la fila de ”todos los datos correspondientes a ese diámetro”. En el código se agrega la siguiente línea If Dn = 0.5 Then x = 7 Cuyo significado es Si Dn tiene el valo 0.5 [in] entonces se trata de la fila 7 La siguiente línea es

More Related